Ruby on Rails Generate Options

Ruby on Rails Generate Options

There are many useful rails generate commands. I’ve listed some of them below for your reference:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Creates a model and controller, then adds a resource route to your routes.rb file.
rails g resource <attribute>:<type>  <attribute>:<type>

# Just like rails g scaffold, but doesn't create the model.
rails g scaffold_controller <name>

# Creates a coffeescript/javascript and corresponding (s)css file.
rails g assets <name>

# Creates a jbuilder file
rails g jbuilder <name> <field>:<type> <field>:<type>

# Creates a custom helper.
rails g helper <name>

# Allows you to create your own custom generates to be used with rails generate.
rails g generator <name>

# Creates a rake task.
rails g <namespace> <task_name> <task_name>

For a complete list of all generate commands, simply run rails g or rails generate from within a project.

So far so good, That’s it!!! See ya!!! :)