How to generate controller inside namespace in rails

If you want to gen it:

rails generate controller namespace_name/controller_name

And If you want to rollback this step using:

rails destroy controller namespace_name/controller_name

Use this command..

rails generate controller namespace_name/controller_name


In your case it will be

$ rails g controller admin/controller_name

If we have an app structure like

  • ---controllers
  • --api
  • -v1

and want to generate controller, do:

$ rails g controller api/v1/controller_name

In general

$ rails g controller namespace_1/namespace_2/...../controller_name

Try rails g controller admin/users if you want a users controller inside of the admin namespace. Of course, exchange users with whatever controller name that you'd like.