rails-snippets

Snippets for your ruby on rails projects.

joseramonc

109,384

126

2.26.0

MIT

GitHub

rails-snippets package

An atom package to add snippets for Ruby on Rails projects.

Developed with Ruby 1.9 syntax (key: 'value') and rails 5 onwards in mind, but most snippets work on older versions too.

Contributions are greatly appreciated, if your favorite snippets are missing open an issue or send a pull request, I would ❤️ to merge your favorite snippets.

Please fork this repository and open a pull request to add / improve snippets.

Features

Toggle with: cmd + >

(In american keyboard: shift + cmd + .)

[OPTIONAL] Customize ERB Blocks

In your atom configuration file (config.cson). Insert each erb block you'd like as an array with the first element as the opening erb and the 2nd element as the closing erb into rails-snippets's erbBlocks configuration array.

As an example of how'd look like:

# config.cson
"*":
  # all your other configs...
  "rails-snippets":
      erbBlocks: [
        ['<%=', '%>']
        ['<%', '%>']
        ['<%#', '%>']
      ]

If you can stick to the default (above) you don't have to do anything. Otherwise add or remove erb blocks in the order you'd like.

Conventions

The conventions for the snippets are usually the initials for the method.

Examples:

Also if the method has an optional block like content_tag (snippet is ct), its block it's going to be adding block to the shortcut, in this case ctblock

Snippets list

Here are some of my favorites snippets, a complete list of snippets can be seen directly at the code or once the package is installed at Settings > Packages > Rails Snippets

=loop

=loop_demo

form_for and fsf

=form_for fsf

scope + (p l bd j jp)

=form_for fsf