Show Menu
Cheatography

Rails FHS Navigation Commands Cheat Sheet (DRAFT) by

vim short cuts for Rails development

This is a draft cheat sheet. It is a work in progress and is not finished yet.

File Type Navigation Commands

:Econt­roller
:Scont­roller
:Scont­roller events
:Scont­roller events­/re­gis­tra­tions
:Scont­roller eve↹
:Scont­roller regi↹
:Scont­roller events­#index
:Scont­roller events­#show
:Scont­roller events:15
:Scont­roller events­/up­coming!
:Scont­roller events!
:Scont­roller events­/re­gis­tra­tions!
 
:Senvi­ronment
:Senvi­ronment develo­pment
:Senvi­ronment pro↹
:Senvi­ronment test
 
:Sfixtures
 
:Sfunc­tio­naltest
 
:Shelper
 
:Sinit­ializer
:Sinit­ializer inflec­tions
 
:Sinit­ializer lograge!
 
:Sinte­gra­tio­ntest
 
:Sjava­script
 
:Slayout
 
:Slib
 
:Sspec
 
:Slocale
 
:Smailer
 
:Smigr­ation
Smigration regi↹
 
:Smodel
:Smodel <C-­a> <C-­a>
:Smodel event!
 
:Smigr­ation
 
:Smodel
 
:Sschema
 
:Sstyl­esheet
 
:Stask
 
:Sunittest
 
:Sview index.h­tm­l.erb
:Sview index.h­tm.erb!
:Sview events­/up­com­ing­/in­dex.ht­ml.erb
:Sview layout­s/_­foo­ter.ht­ml.erb!
Each of the following commands has variants for splitting, vertical splitting, opening in a new tab, and reading the file into the current buffer. For :Emodel, those variants would be :Smodel, :Vmodel, :Tmodel, and :Dmodel.
 

gf or C-w f (* indicates cursor position)

Pos*t.f­irst
app/mo­del­s/p­ost.rb
has_many :c*omments
app/mo­del­s/c­omm­ent.rb
link_to 'Home', :contr­oller => 'bl*og'
app/co­ntr­oll­ers­/bl­og_­con­tro­ller.rb
<%= render 'sh*ar­ed/­sid­ebar' %>
app/vi­ews­/sh­are­d/_­sid­eba­r.h­tml.erb
<%= styles­hee­t_l­ink_tag 'appl*­ica­tion' %>
app/as­set­s/s­tyl­esh­eet­s/a­ppl­ica­tio­n.css
class BlogCo­ntr­oller < Applic­a*t­ion­Con­troller
app/co­ntr­oll­ers­/ap­pli­cat­ion­_co­ntr­oll­er.rb
class Applic­ati­onC­ont­roller < Action­Con­t*r­oll­er:­:Base
.../ac­tio­n_c­ont­rol­ler­/ba­se.rb
fixtures :pos*ts
test/f­ixt­ure­s/p­ost­s.yml
layout :pri*nt
app/vi­ews­/la­you­ts/­pri­nt.h­tm­l.erb
<%= link_to "­New­", new_co­mme­*nt­_path %>
app/co­ntr­oll­ers­/co­mme­nts­_co­ntr­oll­er.rb (jumps to def new)
In the last example, the controller and action for the named route are determined by evaluating routes.rb as Ruby and doing some intros­pec­tion. This means code from the applic­ation is executed. Keep this in mind when navigating unfamiliar applic­ations.

Snippet Rails

routes.rb
r
 
XXXXX_­con­tro­ller.rb
ci || cindex
def index
cni || cnindex
def index (nested)
cs || cshow
def show
cns || cnshow
def show (nested)
cn || cnew
def new
cnn || cnnew
def new (nested)
cc || ccreated
def create
cnc || cncreate
def create (nested)
ce || cedit
def edit
cne || cnedit
def edit (nested)
cu || cupdate
def update
cnu || cnupdate
def update (nested)
cd || cdestroy
def destroy
cnd || cndestroy
def destroy (nested)