Namespace Issues

Abstract: It seems that the AnyModule::AnyModel shadows AnyModel.

Note: a simila post of mine appears in “Rails Engines development” as

The goal

I would like to have the model

in apps/models/any_module/any_model.rb

managed by the controller

in apps/controllers/any_module/any_models_controller.rb

with views
in apps/views/any_module/any_models

I am experimentig a quite strange behavior:

1 - create a test rails application (e.g. tasklist)
2 - setup a db (e.g. tasklist_dev) with a table (e.g. categories)
3 - from RAILS_ROOT
$ ./script generate scaffold category
4 - run the application and
point to http://localhost:3000/categories
you should see the usual good stuff.
5 - $ ./script generate model task_list/category

Now tha application is broken and you get:
“uninitialized constant Category” error.

It seems that the Task_List::Category shadows Category.
Can anybody explain why? Is it already happened to anybody else?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs