views:

52

answers:

1

Hi guys,

Rails 3 scaffold generator places model classes inside namespace. Example:

rails generate scaffold admin/portfolio

But I want only controllers and views to be placed inside admin namespace.

How can I avoid that?

Regards, Alexey Zakharov.

+2  A: 

rails generate model Portfolio

rails generate controller Admin::Portfolios

Jed Schneider
How scaffold view would be generated in this case?
Alexey Zakharov
when you generate the controller, it creates the views as well. if you pass actions, eg (index, show, etc) to the generate controller command, it will build those specific views and stub out the controller actions.
Jed Schneider
You are right Jed. But it generates only empty views.
Alexey Zakharov
at some point we all have to write some code :P
Jed Schneider
It is also possible to use scaffold_controller that will also use namespaced model, but in this case there is no need to fix model namespace.
Alexey Zakharov