Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Sublime Text snippets for the latest Ruby and Rails versions
XML
branch: master
Failed to load latest commit information.
messages Readme
$LABEL.sublime-snippet Move the snippets out of folder for easier installation
%3C%=-Fixtures_identify(%3Asymbol)-%%3E.sublime-snippet Move the snippets out of folder for easier installation
.gitignore Add .gitignore with *.cache
180-rails-form_tag.sublime-snippet use start_expr for form_for and form_tag helpers (Fixes erb problem)
Create-binary-column.sublime-snippet Move the snippets out of folder for easier installation
Create-boolean-column.sublime-snippet Move the snippets out of folder for easier installation
Create-controller-class.sublime-snippet Improve controller class snippet [con]
Create-date-column.sublime-snippet Move the snippets out of folder for easier installation
Create-datetime-column.sublime-snippet Move the snippets out of folder for easier installation
Create-decimal-column.sublime-snippet Move the snippets out of folder for easier installation
Create-float-column.sublime-snippet Move the snippets out of folder for easier installation
Create-functional-test-class.sublime-snippet Move the snippets out of folder for easier installation
Create-integer-column.sublime-snippet Move the snippets out of folder for easier installation
Create-lock_version-column.sublime-snippet Move the snippets out of folder for easier installation
Create-references-column.sublime-snippet Move the snippets out of folder for easier installation
Create-string-column.sublime-snippet Move the snippets out of folder for easier installation
Create-text-column.sublime-snippet Move the snippets out of folder for easier installation
Create-time-column.sublime-snippet Move the snippets out of folder for easier installation
Create-timestamp-column.sublime-snippet Move the snippets out of folder for easier installation
Create-timestamps-columns.sublime-snippet Move the snippets out of folder for easier installation
HTML (Rails).tmLanguage Move the snippets out of folder for easier installation
JavaScript (Rails).tmLanguage Move the snippets out of folder for easier installation
Migration-Add-Column.sublime-snippet Make options a little more flexible
Migration-Add-Index.sublime-snippet Make options a little more flexible
Migration-Change-Column.sublime-snippet Make options a little more flexible
Migration-Create-Column-(mcc).sublime-snippet Move the snippets out of folder for easier installation
Migration-Create-Column-Continue-(mccc).sublime-snippet Move the snippets out of folder for easier installation
Migration-Create-Table-(mdct).sublime-snippet mtab does both create and drop table. Fixes #2
Migration-Drop-Table-(mdct).sublime-snippet mtab does both create and drop table. Fixes #2
Migration-Remove-Column.sublime-snippet Fix Add/Remove column in migrations
Migration-Remove-Index.sublime-snippet Make options a little more flexible
Migration-Rename-Column.sublime-snippet Make options a little more flexible
RAILS_DEFAULT_LOGGER.debug-(rdb).sublime-snippet Move the snippets out of folder for easier installation
README.md Update and simplify README
Ruby Haml Comments.tmPreferences Move the snippets out of folder for easier installation
Ruby Haml.tmLanguage Make Haml's escaping &= appear the same as =
Ruby on Rails.tmLanguage Add _action to support.function.actionpack.rails
SQL (Rails).tmLanguage Move the snippets out of folder for easier installation
Table-column(s)-rename.sublime-snippet Move the snippets out of folder for easier installation
Template (ERB).tmPreferences No need for - in erb ends
Template (Haml).tmPreferences Move the snippets out of folder for easier installation
Test-Assert-Redirected-To-(art).sublime-snippet Move the snippets out of folder for easier installation
Test-Assert-Response-(are).sublime-snippet Move the snippets out of folder for easier installation
accepts_nested_attributes_for.sublime-snippet Add accepts_nested_attributes_for [anaf]
active-record-class-end.sublime-snippet Move the snippets out of folder for easier installation
after_create.sublime-snippet Move the snippets out of folder for easier installation
after_destroy.sublime-snippet Move the snippets out of folder for easier installation
after_save.sublime-snippet Move the snippets out of folder for easier installation
after_update.sublime-snippet Move the snippets out of folder for easier installation
after_validation.sublime-snippet Move the snippets out of folder for easier installation
after_validation_on_create.sublime-snippet Update legacy '<before|after>_validation_on_<create|update>' callbacks
after_validation_on_update.sublime-snippet Update legacy '<before|after>_validation_on_<create|update>' callbacks
assert(var-=-assigns(%3Avar)).sublime-snippet Move the snippets out of folder for easier installation
assert_difference.sublime-snippet Move the snippets out of folder for easier installation
assert_no_difference.sublime-snippet Move the snippets out of folder for easier installation
assert_redirected_to-(nested-path).sublime-snippet Move the snippets out of folder for easier installation
assert_redirected_to-(nested-path-plural).sublime-snippet Move the snippets out of folder for easier installation
assert_redirected_to-(path).sublime-snippet Move the snippets out of folder for easier installation
assert_redirected_to-(path-plural).sublime-snippet Move the snippets out of folder for easier installation
assert_select.sublime-snippet Move the snippets out of folder for easier installation
before_create.sublime-snippet Move the snippets out of folder for easier installation
before_destroy.sublime-snippet Move the snippets out of folder for easier installation
before_save.sublime-snippet Move the snippets out of folder for easier installation
before_update.sublime-snippet Move the snippets out of folder for easier installation
before_validation.sublime-snippet Move the snippets out of folder for easier installation
before_validation_on_create.sublime-snippet Update legacy '<before|after>_validation_on_<create|update>' callbacks
before_validation_on_update.sublime-snippet Update legacy '<before|after>_validation_on_<create|update>' callbacks
belongs_to-(bt).sublime-snippet Move the snippets out of folder for easier installation
binding_pry.sublime-snippet Add bp for binding.pry
cattr_accessor.sublime-snippet Move the snippets out of folder for easier installation
class-end.sublime-snippet Move the snippets out of folder for easier installation
crud-actions.sublime-snippet Cleanup old snippets
def-create-resource.sublime-snippet Move the snippets out of folder for easier installation
def-get-request.sublime-snippet Move the snippets out of folder for easier installation
def-post-request.sublime-snippet Move the snippets out of folder for easier installation
end.sublime-snippet No need for - in erb ends
find(id).sublime-snippet Move the snippets out of folder for easier installation
find_params_id_(fp).sublime-snippet Add find(params[:id]) in controllers [fp]
for-loop-erb.sublime-snippet Move the snippets out of folder for easier installation
form_for-check_box.sublime-snippet Move the snippets out of folder for easier installation
form_for-checkbox.sublime-snippet Move the snippets out of folder for easier installation
form_for-file_field-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-file_field.sublime-snippet Move the snippets out of folder for easier installation
form_for-hidden_field-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-hidden_field.sublime-snippet Move the snippets out of folder for easier installation
form_for-label-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-label.sublime-snippet Move the snippets out of folder for easier installation
form_for-password_field-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-password_field.sublime-snippet Move the snippets out of folder for easier installation
form_for-radio_box-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-radio_box.sublime-snippet Move the snippets out of folder for easier installation
form_for-submit-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-submit.sublime-snippet Move the snippets out of folder for easier installation
form_for-text_area-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-text_area.sublime-snippet Move the snippets out of folder for easier installation
form_for-text_field-2.sublime-snippet Move the snippets out of folder for easier installation
form_for-text_field.sublime-snippet Move the snippets out of folder for easier installation
form_for-with-errors.sublime-snippet Move the snippets out of folder for easier installation
form_for.sublime-snippet use start_expr for form_for and form_tag helpers (Fixes erb problem)
has_and_belongs_to_many-(habtm).sublime-snippet Move the snippets out of folder for easier installation
has_many-(hm).sublime-snippet Move the snippets out of folder for easier installation
has_many-(through).sublime-snippet Move the snippets out of folder for easier installation
has_many-dependent-=-destroy.sublime-snippet Move the snippets out of folder for easier installation
has_one-(ho).sublime-snippet Move the snippets out of folder for easier installation
has_one_through-(hot).sublime-snippet Add has_one through
image_submit_tag.sublime-snippet Move the snippets out of folder for easier installation
initializer-method.sublime-snippet Fix typo
javascript_include_tag-(jit).sublime-snippet Add cache option for javascript_include_tag
lia.sublime-snippet Move the snippets out of folder for easier installation
liai.sublime-snippet Move the snippets out of folder for easier installation
lic.sublime-snippet Move the snippets out of folder for easier installation
lica.sublime-snippet Move the snippets out of folder for easier installation
licai.sublime-snippet Move the snippets out of folder for easier installation
link_to-(nested-path).sublime-snippet Move the snippets out of folder for easier installation
link_to-(nested-path-plural).sublime-snippet Move the snippets out of folder for easier installation
link_to-(path).sublime-snippet Move the snippets out of folder for easier installation
link_to-(path-plural).sublime-snippet Move the snippets out of folder for easier installation
link_to-model.sublime-snippet Move the snippets out of folder for easier installation
logger_debug.sublime-snippet Move the snippets out of folder for easier installation
logger_error.sublime-snippet Move the snippets out of folder for easier installation
logger_fatal.sublime-snippet Move the snippets out of folder for easier installation
logger_info.sublime-snippet Move the snippets out of folder for easier installation
logger_warn.sublime-snippet Move the snippets out of folder for easier installation
map(-%3Asym_proc).sublime-snippet Move the snippets out of folder for easier installation
mattr_accessor.sublime-snippet Move the snippets out of folder for easier installation
messages.json Installation instructions
named_scope-lambda.sublime-snippet Move the snippets out of folder for easier installation
rails-flash.sublime-snippet Move the snippets out of folder for easier installation
rea.sublime-snippet Move the snippets out of folder for easier installation
reai.sublime-snippet Move the snippets out of folder for easier installation
rec.sublime-snippet Move the snippets out of folder for easier installation
reca.sublime-snippet Move the snippets out of folder for easier installation
recai.sublime-snippet Move the snippets out of folder for easier installation
redirect_to-(nested-path).sublime-snippet Move the snippets out of folder for easier installation
redirect_to-(nested-path-plural).sublime-snippet Move the snippets out of folder for easier installation
redirect_to-(path).sublime-snippet Move the snippets out of folder for easier installation
redirect_to-(path-plural).sublime-snippet Move the snippets out of folder for easier installation
render-(action)...-(ra).sublime-snippet Move the snippets out of folder for easier installation
render-(action-layout)-(ral).sublime-snippet Move the snippets out of folder for easier installation
render-(file)-(rf).sublime-snippet Move the snippets out of folder for easier installation
render-(file-use_full_path)-(rfu).sublime-snippet Move the snippets out of folder for easier installation
render-(inline)-(ri).sublime-snippet Move the snippets out of folder for easier installation
render-(inline-locals)-(ril).sublime-snippet Move the snippets out of folder for easier installation
render-(inline-type)-(rit).sublime-snippet Move the snippets out of folder for easier installation
render-(layout)-(rl).sublime-snippet Move the snippets out of folder for easier installation
render-(nothing)-(rn).sublime-snippet Move the snippets out of folder for easier installation
render-(nothing-status)-(rns).sublime-snippet Move the snippets out of folder for easier installation
render-(partial)-(rp).sublime-snippet Use shorthand partial rendering syntax
render-(partial-collection)-(rpc).sublime-snippet Enable [rpc] and [rpo] snippets in haml
render-(partial-object)-(rpo).sublime-snippet Enable [rpc] and [rpo] snippets in haml
render-(partial-status)-(rps).sublime-snippet Move the snippets out of folder for easier installation
render-(text)-(rt).sublime-snippet Move the snippets out of folder for easier installation
render-(text-layout)-(rtl).sublime-snippet Move the snippets out of folder for easier installation
render-(text-layout=%3Etrue)-(rtlt).sublime-snippet Move the snippets out of folder for easier installation
render-(text-status)-(rts).sublime-snippet Move the snippets out of folder for easier installation
render-(update).sublime-snippet Move the snippets out of folder for easier installation
respond_to.sublime-snippet Move the snippets out of folder for easier installation
returning-do-%7Cvariable%7C-%E2%80%A6-end.sublime-snippet Move the snippets out of folder for easier installation
routes_resource_only.sublime-snippet Rails 3 type route generation
routes_resources.sublime-snippet Rails 3 type route generation
routes_resources_block.sublime-snippet Rails 3 type route generation
routes_resources_collection_block.sublime-snippet Rails 3 type route generation
routes_resources_member_block.sublime-snippet Rails 3 type route generation
scope.sublime-snippet Change scope to use lambda and where
scope_with_args.sublime-snippet Add sope with arguments snippet [scar]
stylesheet_link_tag-(slt).sublime-snippet Rename tag to standard and correct landing point for tab trigger
submit_tag.sublime-snippet Move the snippets out of folder for easier installation
t_binary-(tcbi).sublime-snippet Move the snippets out of folder for easier installation
t_boolean-(tcb).sublime-snippet Move the snippets out of folder for easier installation
t_date-(tcda).sublime-snippet Move the snippets out of folder for easier installation
t_datetime-(tcdt).sublime-snippet Move the snippets out of folder for easier installation
t_decimal-(tcd).sublime-snippet Move the snippets out of folder for easier installation
t_float-(tcf).sublime-snippet Move the snippets out of folder for easier installation
t_integer-(tci).sublime-snippet Move the snippets out of folder for easier installation
t_lock_version-(tcl).sublime-snippet Move the snippets out of folder for easier installation
t_references-(tcr).sublime-snippet Move the snippets out of folder for easier installation
t_rename-(tre).sublime-snippet Move the snippets out of folder for easier installation
t_string-(tcs).sublime-snippet Move the snippets out of folder for easier installation
t_text-(tct).sublime-snippet Move the snippets out of folder for easier installation
t_time-(tcti).sublime-snippet Move the snippets out of folder for easier installation
t_timestamp-(tcts).sublime-snippet Move the snippets out of folder for easier installation
t_timestamps-(tctss).sublime-snippet Move the snippets out of folder for easier installation
validates_acceptance_of-if.sublime-snippet Move the snippets out of folder for easier installation
validates_acceptance_of.sublime-snippet Move the snippets out of folder for easier installation
validates_associated-(va).sublime-snippet Move the snippets out of folder for easier installation
validates_associated-if-(vaif).sublime-snippet Move the snippets out of folder for easier installation
validates_confirmation_of-(vc).sublime-snippet Move the snippets out of folder for easier installation
validates_confirmation_of-if-(vcif).sublime-snippet Move the snippets out of folder for easier installation
validates_exclusion_of-(ve).sublime-snippet Move the snippets out of folder for easier installation
validates_exclusion_of-if-(veif).sublime-snippet Move the snippets out of folder for easier installation
validates_format_of-if.sublime-snippet Move the snippets out of folder for easier installation
validates_format_of.sublime-snippet Move the snippets out of folder for easier installation
validates_inclusion_of-if.sublime-snippet Move the snippets out of folder for easier installation
validates_inclusion_of.sublime-snippet Move the snippets out of folder for easier installation
validates_length_of-(vl).sublime-snippet Move the snippets out of folder for easier installation
validates_length_of-if.sublime-snippet Move the snippets out of folder for easier installation
validates_numericality_of-if.sublime-snippet Move the snippets out of folder for easier installation
validates_numericality_of.sublime-snippet Move the snippets out of folder for easier installation
validates_presence_of-(vp).sublime-snippet Move the snippets out of folder for easier installation
validates_presence_of-if-(vpif)-2.sublime-snippet Move the snippets out of folder for easier installation
validates_uniqueness_of-(vu).sublime-snippet Move the snippets out of folder for easier installation
validates_uniqueness_of-if-(vuif).sublime-snippet Move the snippets out of folder for easier installation
verify-(verify).sublime-snippet Move the snippets out of folder for easier installation
wants_format.sublime-snippet Move the snippets out of folder for easier installation
xhr-delete.sublime-snippet Move the snippets out of folder for easier installation
xhr-get.sublime-snippet Move the snippets out of folder for easier installation
xhr-post.sublime-snippet Move the snippets out of folder for easier installation
xhr-put.sublime-snippet Move the snippets out of folder for easier installation

README.md

Sublime Text Rails snippets

The repo aims to replace the default Rails snippets from Sublime Text and make it useful for the latest Ruby and Rails versions. All the snippets can be found in this cheatsheet generated by Snipcheat.

class

ActiveRecord

migrations

Installation

From Git

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
➜ git clone https://github.com/tadast/sublime-rails-snippets.git Rails

It is important to clone it into a folder called Rails. Some Sublime plugins have hardcoded dependencies pointing to that path. See troubleshooting.

From Package Control

Look for "Ruby on Rails snippets". Here's how to install packages

Housekeeping

:warning: You will need to do some housekeeping after installing it from Package Control. First of all, remove the original Rails directory (see Backup). Then quit Sublime and delete Sublime's session cache.

rm ~/Library/Application\ Support/Sublime\ Text\ 2/Settings/Session.sublime_session

This will lose all session data (Sublime will 'forget' open filetabs, projects, search history etc.)

Troubleshooting

Can't find *.tmLanguage

If Sublime complains it can't find Ruby on Rails.tmLanguage, chances are you are using this hack.

You'll need to change the path where it looks for that file. Here's the forked version which works with this plugin.

You may also need to change Packages/(DetectSyntax|User)/DetectSyntax.sublime-settings to replace/include this rule

{
  "name": "Ruby on Rails snippets/Ruby Haml",
  "rules": [
    {"file_name": ".*\\.haml$"}
  ]
},
{
  "name": "Ruby on Rails snippets/Ruby on Rails",
  "rules": [
    {"function": {"name": "is_rails_file"}}
  ]
}

Ruby on Rails snippets is a default instalation directory for Package Control. If you installed in a different directory, change the path accordingly

Sublime picks Ruby syntax

You may need to tell Sublime to prefer Rails View -> Syntax -> Open all with current extension as... and pick Rails of Ruby on Rails snippets

How to contribute

  1. Fork it
  2. Create your feature branch for each group of snippet changes that could be merged individually (git checkout -b my-new-snippet)
  3. Commit your changes (git commit -am 'Add some snippet [tab_trigger]')
  4. Commit messages should start with a verb in present simple tense and have all affected tab triggers in square brackets e.g. "Add a snippets for partial rendering [rpc, rpo]"
  5. Push to the branch (git push origin my-new-snippet)
  6. Create new Pull Request
Something went wrong with that request. Please try again.