This project is archived and is in readonly mode.
[PATCH]Rails 3 : Namespace problem in Scaffold
-
siddick
Actual configuration in the routes.rb is
resources :rolesBut the expected is
namespace :admin doresources :roles
end
-
siddick
- Title changed from Generate Scaffold problem to Rails 3 : Namespace problem in Scaffold
-
siddick
- Tag changed from 3.0.0.beta3 to 3.0.0.beta3, patch
- Title changed from Rails 3 : Namespace problem in Scaffold to [PATCH]Rails 3 : Namespace problem in Scaffold
I created PATCH, which will solve the namespace problem in scaffold.
Steps to reproduce the BUG( Rails 3.0.0.beta4, ruby 1.8.7 ) :-
siddick@Aristo32:~$ rails new rt siddick@Aristo32:~$ cd rt siddick@Aristo32:~/rt$ rails g scaffold admin/role name:string description:string invoke active_record create db/migrate/20100609114623_create_admin_roles.rb create app/models/admin/role.rb create app/models/admin.rb invoke test_unit create test/unit/admin/role_test.rb [BUG] create test/fixtures/admin_roles.yml [BUG] route resources :roles invoke scaffold_controller create app/controllers/admin/roles_controller.rb invoke erb create app/views/admin/roles create app/views/admin/roles/index.html.erb create app/views/admin/roles/edit.html.erb create app/views/admin/roles/show.html.erb create app/views/admin/roles/new.html.erb create app/views/admin/roles/_form.html.erb invoke test_unit create test/functional/admin/roles_controller_test.rb invoke helper create app/helpers/admin/roles_helper.rb invoke test_unit create test/unit/helpers/admin/roles_helper_test.rb invoke stylesheets create public/stylesheets/scaffold.css siddick@Aristo32:~/rt$ rake routes GET /roles(.:format) {:controller=>"roles", :action=>"index"} roles POST /roles(.:format) {:controller=>"roles", :action=>"create"} new_role GET /roles/new(.:format) {:controller=>"roles", :action=>"new"} GET /roles/:id(.:format) {:controller=>"roles", :action=>"show"} PUT /roles/:id(.:format) {:controller=>"roles", :action=>"update"} role DELETE /roles/:id(.:format) {:controller=>"roles", :action=>"destroy"} edit_role GET /roles/:id/edit(.:format) {:controller=>"roles", :action=>"edit"} siddick@Aristo32:~/rt$ rake db:migrate siddick@Aristo32:~/rt$ rake test Loaded suite /home/siddick/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake/rake_test_loader Started . Finished in 0.119779 seconds. 1 tests, 1 assertions, 0 failures, 0 errors Loaded suite /home/siddick/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake/rake_test_loader Started EEEEEEE Finished in 0.120718 seconds. 1) Error: test_should_create_role(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 2) Error: test_should_destroy_role(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 3) Error: test_should_get_edit(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 4) Error: test_should_get_index(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 5) Error: test_should_get_new(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 6) Error: test_should_show_role(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 7) Error: test_should_update_role(Admin::RolesControllerTest): FixtureClassNotFound: No class attached to find. /test/functional/admin/roles_controller_test.rb:5:in `_callback_before_33' 7 tests, 0 assertions, 0 failures, 7 errorsAfter applying the PATCH :-
siddick@Aristo32:~/rt$ siddick@Aristo32:~$ rails new rt siddick@Aristo32:~$ cd rt siddick@Aristo32:~/rt$ rails g scaffold admin/role name:string description:string invoke active_record create db/migrate/20100609123955_create_admin_roles.rb create app/models/admin/role.rb create app/models/admin.rb invoke test_unit create test/unit/admin/role_test.rb create test/fixtures/admin/roles.yml route namespace :admin do resources :roles end invoke scaffold_controller create app/controllers/admin/roles_controller.rb invoke erb create app/views/admin/roles create app/views/admin/roles/index.html.erb create app/views/admin/roles/edit.html.erb create app/views/admin/roles/show.html.erb create app/views/admin/roles/new.html.erb create app/views/admin/roles/_form.html.erb invoke test_unit create test/functional/admin/roles_controller_test.rb invoke helper create app/helpers/admin/roles_helper.rb invoke test_unit create test/unit/helpers/admin/roles_helper_test.rb invoke stylesheets create public/stylesheets/scaffold.css siddick@Aristo32:~/rt$ rake routes GET /admin/roles(.:format) {:controller=>"admin/roles", :action=>"index"} admin_roles POST /admin/roles(.:format) {:controller=>"admin/roles", :action=>"create"} new_admin_role GET /admin/roles/new(.:format) {:controller=>"admin/roles", :action=>"new"} GET /admin/roles/:id(.:format) {:controller=>"admin/roles", :action=>"show"} PUT /admin/roles/:id(.:format) {:controller=>"admin/roles", :action=>"update"} admin_role DELETE /admin/roles/:id(.:format) {:controller=>"admin/roles", :action=>"destroy"} edit_admin_role GET /admin/roles/:id/edit(.:format) {:controller=>"admin/roles", :action=>"edit"} siddick@Aristo32:~/rt$ rake db:migrate siddick@Aristo32:~/rt$ rake test Loaded suite /home/siddick/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake/rake_test_loader Started . Finished in 0.180626 seconds. 1 tests, 1 assertions, 0 failures, 0 errors Loaded suite /home/siddick/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake/rake_test_loader Started ....... Finished in 0.301821 seconds. 7 tests, 10 assertions, 0 failures, 0 errorsTesting :-
I added testcase to test the namespace problem in scaffold.
rake test:regular TEST=test/generators/scaffold_generator_test.rb -
siddick
- Tag changed from 3.0.0.beta3, patch to rails 3.0.0.beta4, patch, scaffold
Any Updates on this bug..
-
José Valim
- Milestone cleared.
- State changed from new to open
- Assigned user set to José Valim
Hey mate, thanks for the awesome patch with tests! However, it needs to be rebased, could you do it? (Sorry for not being able to see it earlier)
Also, I have one suggestion. I noticed you changed all orm_instance calls to orm_instance(singular_table_name). Wouldn't it be better if you simply change the default value given to orm_instance instead:
http://github.com/rails/rails/blob/master/railties/lib/rails/genera...
It could use singular_table_name instead of file_name.
-
José Valim
- Milestone cleared.
-
siddick
I attached the New Patch, with the changes that you have suggested.
-
José Valim
Sweet! Thanks for the great work!
-
Repository
- State changed from open to resolved
(from [7008911222826eef07a338bf4cab27b83fe90ce1]) Patch for Namespace problem in Scaffold. [#4763 [PATCH]Rails 3 : Namespace problem in Scaffold state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/7008911222826eef07a338bf4cab27... -
siddick
Thanks for all your support..
