DEV Community

Lam
Lam

Posted on

Vim-Rails Cheat Sheet

Config

:Einitializer <file>          # config/initializers/*.rb
:Elocale                      # config/locales/*.yml
:Eenvironment                 # application.rb
:Eenvironment development     # config/environments/*.rb
Enter fullscreen mode Exit fullscreen mode

Test

:Espec
:Eunittest
  # test/{unit,models,helpers}/*_test.rb
  # spec/{unit,models,helpers}/*_spec.rb

:Efunctionaltest
  # test/{functional,controllers,mailers}/*_test.rb
  # spec/{functional,controllers,mailers}/*_spec.rb

:Eintegrationtest
  # test/integration/*_test.rb
  # spec/{features,requests,integration}/*_spec.rb
  # features/*.feature

:Efixtures
:Efunctionaltest
Enter fullscreen mode Exit fullscreen mode

Assets

:Estylesheet
:Ejavascript
Enter fullscreen mode Exit fullscreen mode

Lib

:Elib <file>      # lib/*.rb
:Elib             # Gemfile
:Etask <file>     # lib/tasks/*.rake
Enter fullscreen mode Exit fullscreen mode

DB

:Emigration <file>     # db/migrations/*.rb
:Eschema               # db/schema.rb
Enter fullscreen mode Exit fullscreen mode

App

:Econtroller <file>     # app/controllers/*_controller.rb
:Ehelper                # app/helpers/*_helper.rb
:Emodel <file>          # app/models/*.rb
:Ejob <file>            # app/jobs/*_job.rb
:Emailer <file>         # app/mailers/*.rb
Enter fullscreen mode Exit fullscreen mode

Views

Abbrev Expansion
dotiw distance_of_time_in_words
taiw time_ago_in_words

Extracting partials

# from view => app/views/home/_foo_partial.haml
  :Rextract home/foo_partial

# from model => app/models/concerns/foo_concern.rb
  :Rextract FooConcern
Enter fullscreen mode Exit fullscreen mode

Loading files

Controllers

Abbrev Expansion
pa[ params
re( redirect_to
rp( render partial:
rst( respond_to

Model

Abbrev Expansion
bt( belongs_to
hm( has_many
ho( has_one
habtm( has_and_belongs_to_many

Reference

Latest comments (0)