I use devise, and I want generate a new object scaffold under devise user sth like:
resources :users, :path => "/", :only => [:show] do
resources :collections, :controller => 'users/collections'
end
With above routes, I get this url:
http://localhost:3000/kevin_doe/collections
The problem is that if I issue this command:
rails g scaffold users/collection title:string description:text
This generate a namespace sth like:
namespace :users do resources :collections end
The route that I get is:
http://localhost:3000/users/collections
I want generate a scaffold under devise user resource.
How can I fix this problem?
Thank you!
The fix for this question are the next steps:
1º generate the scaffold with:
rails g scaffold collection title:string description:text
2º Modify your routes.rb file with the nested resource:
resources :users, :path => "/", :only => [:show] do
resources :collections, :controller => 'users/collections'
end
3º you must create a "users" folder
in your controllers directory and move the collections_controller.rb
to
app/controllers/users/
4º in collections_controller.rb
you must modify:
class Users::CollectionsController < ApplicationController
.
.
.
end
5º In your views you must move the folder collections
to app/views/users/collections
Done! :D.