Search code examples
ruby-on-railsrubyruby-on-rails-3scaffolding

Prefix for the rails generators


Is there a way to generate a scaffold with the admin folder prefix..For example I want one Admin folder and a few controllers for that admin folder. I want to do a scaffold for each controller in the admin folder and i wanted to know if there was something like

script/generate scaffold admin:something somefield:string

Solution

  • The scaffold generator can take a namespaced argument:
    
    # Rails 3
    rails g scaffold Admin::Something somefield:string
    
    # Rails 2
    script/generate scaffold Admin::Something somefield:string