Sublime Text snippets for the latest Ruby and Rails versions
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
messages
$LABEL.sublime-snippet
%3C%=-Fixtures_identify(%3Asymbol)-%%3E.sublime-snippet
.gitignore
180-rails-form_tag.sublime-snippet
Create-binary-column.sublime-snippet
Create-boolean-column.sublime-snippet
Create-controller-class.sublime-snippet
Create-date-column.sublime-snippet
Create-datetime-column.sublime-snippet
Create-decimal-column.sublime-snippet
Create-float-column.sublime-snippet
Create-functional-test-class.sublime-snippet
Create-integer-column.sublime-snippet
Create-lock_version-column.sublime-snippet
Create-references-column.sublime-snippet
Create-string-column.sublime-snippet
Create-text-column.sublime-snippet
Create-time-column.sublime-snippet
Create-timestamp-column.sublime-snippet
Create-timestamps-columns.sublime-snippet
HTML (Rails).tmLanguage
JavaScript (Rails).tmLanguage
Migration-Add-Column.sublime-snippet
Migration-Add-Index.sublime-snippet
Migration-Change-Column.sublime-snippet
Migration-Create-Column-(mcc).sublime-snippet
Migration-Create-Column-Continue-(mccc).sublime-snippet
Migration-Create-Table-(mdct).sublime-snippet
Migration-Drop-Table-(mdct).sublime-snippet
Migration-Remove-Column.sublime-snippet
Migration-Remove-Index.sublime-snippet
Migration-Rename-Column.sublime-snippet
RAILS_DEFAULT_LOGGER.debug-(rdb).sublime-snippet
README.md
Ruby Haml Comments.tmPreferences
Ruby Haml.tmLanguage
Ruby on Rails.tmLanguage
SQL (Rails).tmLanguage
Table-column(s)-rename.sublime-snippet
Template (ERB).tmPreferences
Template (Haml).tmPreferences
Test-Assert-Redirected-To-(art).sublime-snippet
Test-Assert-Response-(are).sublime-snippet
accepts_nested_attributes_for.sublime-snippet
active-record-class-end.sublime-snippet
after_create.sublime-snippet
after_destroy.sublime-snippet
after_save.sublime-snippet
after_update.sublime-snippet
after_validation.sublime-snippet
after_validation_on_create.sublime-snippet
after_validation_on_update.sublime-snippet
assert(var-=-assigns(%3Avar)).sublime-snippet
assert_difference.sublime-snippet
assert_no_difference.sublime-snippet
assert_redirected_to-(nested-path).sublime-snippet
assert_redirected_to-(nested-path-plural).sublime-snippet
assert_redirected_to-(path).sublime-snippet
assert_redirected_to-(path-plural).sublime-snippet
assert_select.sublime-snippet
before_create.sublime-snippet
before_destroy.sublime-snippet
before_save.sublime-snippet
before_update.sublime-snippet
before_validation.sublime-snippet
before_validation_on_create.sublime-snippet
before_validation_on_update.sublime-snippet
belongs_to-(bt).sublime-snippet
binding_pry.sublime-snippet
byebug.sublime-snippet
cattr_accessor.sublime-snippet
class-end.sublime-snippet
crud-actions.sublime-snippet
def-create-resource.sublime-snippet
def-get-request.sublime-snippet
def-post-request.sublime-snippet
else.sublime-snippet
end.sublime-snippet
find(id).sublime-snippet
find_params_id_(fp).sublime-snippet
for-loop-erb.sublime-snippet
form_for-check_box.sublime-snippet
form_for-checkbox.sublime-snippet
form_for-file_field-2.sublime-snippet
form_for-file_field.sublime-snippet
form_for-hidden_field-2.sublime-snippet
form_for-hidden_field.sublime-snippet
form_for-label-2.sublime-snippet
form_for-label.sublime-snippet
form_for-password_field-2.sublime-snippet
form_for-password_field.sublime-snippet
form_for-radio_box-2.sublime-snippet
form_for-radio_box.sublime-snippet
form_for-submit-2.sublime-snippet
form_for-submit.sublime-snippet
form_for-text_area-2.sublime-snippet
form_for-text_area.sublime-snippet
form_for-text_field-2.sublime-snippet
form_for-text_field.sublime-snippet
form_for-with-errors.sublime-snippet
form_for.sublime-snippet
has_and_belongs_to_many-(habtm).sublime-snippet
has_many-(hm).sublime-snippet
has_many-(through).sublime-snippet
has_many-dependent-=-destroy.sublime-snippet
has_one-(ho).sublime-snippet
has_one_through-(hot).sublime-snippet
image_submit_tag.sublime-snippet
initializer-method.sublime-snippet
javascript_include_tag-(jit).sublime-snippet
lia.sublime-snippet
liai.sublime-snippet
lic.sublime-snippet
lica.sublime-snippet
licai.sublime-snippet
link_to-(nested-path).sublime-snippet
link_to-(nested-path-plural).sublime-snippet
link_to-(path).sublime-snippet
link_to-(path-plural).sublime-snippet
link_to-model.sublime-snippet
logger_debug.sublime-snippet
logger_error.sublime-snippet
logger_fatal.sublime-snippet
logger_info.sublime-snippet
logger_warn.sublime-snippet
map(-%3Asym_proc).sublime-snippet
mattr_accessor.sublime-snippet
messages.json
named_scope-lambda.sublime-snippet
rails-flash.sublime-snippet
rea.sublime-snippet
reai.sublime-snippet
rec.sublime-snippet
reca.sublime-snippet
recai.sublime-snippet
redirect_to-(nested-path).sublime-snippet
redirect_to-(nested-path-plural).sublime-snippet
redirect_to-(path).sublime-snippet
redirect_to-(path-plural).sublime-snippet
render-(action)...-(ra).sublime-snippet
render-(action-layout)-(ral).sublime-snippet
render-(file)-(rf).sublime-snippet
render-(file-use_full_path)-(rfu).sublime-snippet
render-(inline)-(ri).sublime-snippet
render-(inline-locals)-(ril).sublime-snippet
render-(inline-type)-(rit).sublime-snippet
render-(layout)-(rl).sublime-snippet
render-(nothing)-(rn).sublime-snippet
render-(nothing-status)-(rns).sublime-snippet
render-(partial)-(rp).sublime-snippet
render-(partial-collection)-(rpc).sublime-snippet
render-(partial-object)-(rpo).sublime-snippet
render-(partial-status)-(rps).sublime-snippet
render-(text)-(rt).sublime-snippet
render-(text-layout)-(rtl).sublime-snippet
render-(text-layout=%3Etrue)-(rtlt).sublime-snippet
render-(text-status)-(rts).sublime-snippet
render-(update).sublime-snippet
respond_to.sublime-snippet
returning-do-%7Cvariable%7C-%E2%80%A6-end.sublime-snippet
routes_resource_only.sublime-snippet
routes_resources.sublime-snippet
routes_resources_block.sublime-snippet
routes_resources_collection_block.sublime-snippet
routes_resources_member_block.sublime-snippet
scope.sublime-snippet
scope_with_args.sublime-snippet
stylesheet_link_tag-(slt).sublime-snippet
submit_tag.sublime-snippet
t_binary-(tcbi).sublime-snippet
t_boolean-(tcb).sublime-snippet
t_date-(tcda).sublime-snippet
t_datetime-(tcdt).sublime-snippet
t_decimal-(tcd).sublime-snippet
t_float-(tcf).sublime-snippet
t_integer-(tci).sublime-snippet
t_lock_version-(tcl).sublime-snippet
t_references-(tcr).sublime-snippet
t_rename-(tre).sublime-snippet
t_string-(tcs).sublime-snippet
t_text-(tct).sublime-snippet
t_time-(tcti).sublime-snippet
t_timestamp-(tcts).sublime-snippet
t_timestamps-(tctss).sublime-snippet
validates_acceptance_of-if.sublime-snippet
validates_acceptance_of.sublime-snippet
validates_associated-(va).sublime-snippet
validates_associated-if-(vaif).sublime-snippet
validates_confirmation_of-(vc).sublime-snippet
validates_confirmation_of-if-(vcif).sublime-snippet
validates_exclusion_of-(ve).sublime-snippet
validates_exclusion_of-if-(veif).sublime-snippet
validates_format_of-if.sublime-snippet
validates_format_of.sublime-snippet
validates_inclusion_of-if.sublime-snippet
validates_inclusion_of.sublime-snippet
validates_length_of-(vl).sublime-snippet
validates_length_of-if.sublime-snippet
validates_numericality_of-if.sublime-snippet
validates_numericality_of.sublime-snippet
validates_presence_of-(vp).sublime-snippet
validates_presence_of-if-(vpif)-2.sublime-snippet
validates_uniqueness_of-(vu).sublime-snippet
validates_uniqueness_of-if-(vuif).sublime-snippet
verify-(verify).sublime-snippet
wants_format.sublime-snippet
xhr-delete.sublime-snippet
xhr-get.sublime-snippet
xhr-post.sublime-snippet
xhr-put.sublime-snippet

README.md

Sublime Text Rails snippets

⚠️ I'll be porting these changes to the official Sublime Text Rails snippets. Here's how you can help

This repo provides up-to-date Ruby and Rails snippets for Sublime Text: it's designed to be used with Ruby >= 2.0 and Rails >= 3. All the snippets can be found in this cheatsheet generated by Snipcheat.

class

ActiveRecord

migrations

Installation

If you're using Sublime Text 2, please refer to older installation instructions.

From Package Control

The easiest way to install the snippets is via package control.

However this method has a little downside: it adds new snippets but does not remove the old ones. This means that for some snippet triggers e.g. vp (validates presence) you'll see a drop-down with two options, not one.

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

From Git

This method replaces the default outdated snippets, but you have to keep it up to date manually by running git pull every now and again.

To install via git:

  • First, cd into the ST3 Packages directory
# Mac:cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages
➜ # Linux:cd ~/.config/sublime-text-3/Packages/
  • Then clone this repo into the folder
➜ ls | grep Rails
➜ # if there is a `Rails` dir, back it up e.g. archive it and remove the original.
➜ 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 hard-coded dependencies pointing to that path. See troubleshooting.

Troubleshooting

Syntax highlighting doesn't work

You might need to tell Sublime text to use the Ruby on Rails syntax provided by Ruby on Rails Snippets. With an .rb file open and focused navigate to View -> Syntax -> Open all with current extension as... -> Ruby on Rails Snippets -> Ruby on Rails

Sublime picks Ruby (not Rails) syntax

You might need to tell Sublime to prefer Rails over Ruby by navigating to View -> Syntax -> Open all with current extension as... and picking Rails of Ruby on Rails snippets

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 plug-in.

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 installation directory for Package Control. If you installed in a different directory, change the path accordingly

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