TextMate Ruby/Rails/SQL/YAML Cheat Sheet
RUBY COMMANDS ⌃⌥⇧R RUBY SNIPPETS RUBY CLASSES
Ruby rcode completion ⌥⎋ require “..” req⇥ New Ruby (Rails) class cla⇥
Run rake task ⌃⇧R File (foreach, read, open) File⇥ def self.name .. end defs⇥
Run current UnitTest ⌘⇧R Option parser block optp⇥ alias_method :new, :old am⇥
Open require ⌘⇧D Add option opt⇥ attr_[read,write,access] .. [r,w,rw]⇥
Insert missing requires ⌃# UnitTest, TestCase block tc⇥
Execute Line/Selection ⌃⇧E def test_name .. end deft⇥ RUBY FUNCTIONAL
SQL COMMANDS ⌃⌥⇧S assert test, message as⇥ Array.new(..) { |i| .. } Array⇥
Database browser ⌥⌘⇧D assert_(([a-z])[a-z]+_?)+ as[a-z]+⇥ Hash.new { |h,k| h[k] = .. } Hash⇥
Execute line/selection ⌃⇧Q New rdoc block =b⇥ [all,any]? { |e| .. } [all,any]⇥
RUBY CODE [case, elsif, if, unless, each { |e| .. } ea⇥
[...⇥
Toggle string/symbol ⌃: when, while] block each_(([a-z])[a-z]+_?)+ ea[a-z]+⇥
Toggle do .. end / { .. } ⌃{ If .. else .. end ife⇥ reverse_each { |e| .. } reve⇥
Insert/toggle ERb (select.) ⌃> New module mod⇥ inject(init) { |mem, var| .. } inj⇥
Add ! to method in line ⌃! :key => “value”[,] :⇥ lambda { |args| .. } lam⇥
Begin .. rescue .. end ⌃⇧W :yieds: arguments y⇥ map { |e| .. } map⇥
Hash pointer ʻ => ʻ ⌃L { |variables| .. } {⇥ map_with_index { |e, i| .. } mapwi⇥
Embed select. code #{..} # do |variables| .. end do⇥ zip(enums) { |row| .. } zip⇥
TextMate Ruby/Rails/SQL/YAML Cheat Sheet
TextMate Ruby/Rails/SQL/YAML Cheat Sheet
RAILS COMMANDS ⌃⌥⇧R RAILS SNIPPETS find([:all,:first,id]) fin[a,f,i]⇥
Show classʼ DB schema ⌃⌘⇧S “session[:user]” snippet ⌃J logger.level logl⇥
Goto alternate file ⌥⌘↓ “params[:id]” snippet ⌃P returning do |var| .. end returning⇥
Goto specific file ⌥⌘⇧↓ flash[:notice] = “msg” flash⇥ xhr [get,post,put,delete] x[…]⇥
Goto file on current line ⌥⌘↑ [c,m]attr_accessor :name [c,m]rw⇥ SCOPE REFERENCE
Generators, migrations, redirect_to ([something]+) re[s]+⇥ CONTROLLER
⌃| (pipe)
fixtures, schema cmds render ([something]+) r[s]+⇥ respond to (sel. text) ⌘⇧H
Generate a migration ⌃⇧M verify [redirect, render] verify⇥ def create method block defcreate⇥
Test ... (rake test tasks) ⌃\ assert(v = assigns(:v)) asg⇥ CUCUMBER ⌃⌥⇧C
assert_response asre⇥ Feature fea⇥
YAML COMMANDS ⌃⌥⇧Y assert_rjs asrj⇥ Scenario, Outline sc[e,o]⇥
Autocomplete FK fixture associations: use initials ...⇥ [Given, When, Then] step [giv,whe,the]⇥
⌥[⇧]⎋
reference [habtm] has_many :dependent hmd⇥ Autocomplete step ⌥⎋
key: value snippet ⌃: has_many :through hmt⇥ Create all undef. steps ⌃⌥⌘⇧↓
Convert to Ruby ⌃⇧H validates_(([a-z])[a-z]+_?)+ Goto current step ⌃⌥⇧↓
v[a-z]+⇥
Syntax cheat sheet ⌃H (w/o “_of”, add “if” for :if) Run feature ⌘R
Add list item ⌅ before_[a-z][a-z]+ bef[cdus]⇥ Run single scenario ⌘⇧R
Sort keys alphabetically F5 after_[a-z][a-z]+ aft[cdus]⇥ Align table cells ⌥⌘\
TextMate Ruby/Rails/SQL/YAML Cheat Sheet
TextMate Ruby/Rails/SQL/YAML Cheat Sheet
MIGRATIONS RSPEC Story block st⇥
Manipulate table mtab⇥[⇥] Run focused example ⌘⇧R VIEW
Manipulate colum[s] mcol⇥[⇥] Run behaviour descript. ⌘R Refactor select. to partial ⌃⇧H
Create columns mccc⇥ Run BD of select. files/dir ⌥⌘R form_for [with errors] ff[e]⇥
Rename column[s] mncc⇥ describe “description” des⇥ f.method (snippet name) f.⇥
Manipulate index mind⇥ describe Type dest⇥ [form, submit,
[f,s,is]t⇥
t.column (snippet name) t.⇥ descript Type, “descript.” dests⇥ image_submit]_tag
RJS describe Controller desc⇥ link_to [something]+ li[s]+⇥
page.hide hide⇥ describe REST Controller desrc⇥ If .. for .. end else .. end for⇥
page.insert_html ins⇥ it “should ..” do .. end it⇥ <% end %> end⇥
page.replace rep⇥ before :each do .. end bef⇥ javascript_include_tag jit⇥
page.replace_html reph⇥ after :each do .. end aft⇥ stylesheet_link_tag slt⇥
page.show show⇥ Custom matcher block mat⇥ WEBRAT
page.toggle tog⇥ target.should [someth]+ sh[=s]+⇥ attach_file name, “path” atf⇥
page.visual_effect vis⇥ target.should_not [sth]+ shn[=s]+⇥ click_… ʻ…ʼ cli⇥
ROUTES var = mock(“name”) moc⇥ fill_in ʻnameʼ, :with ʻvalueʼ fil⇥
map [resources, resource map[rs,r, Require spec_helper resh⇥ save_and_open_page sav⇥
with_options, catch_all] wo,ca]?⇥ controller_name :name conn⇥ select ʻ..ʼ {.., :from => ʻ..ʼ} sel⇥
TextMate Ruby/Rails/SQL/YAML Cheat Sheet