Abstract: It seems that the AnyModule::AnyModel shadows AnyModel.
-----------------------------------------------------------------
If you are in a hurry, please skip to "The Problem".
The idea
----------
One important topic in architecting engines is to make them as isolated
as possible in terms of namespace and database schema (if supported).
In this way we can be confident that our engine can be used by other
applications without risk of name clashes.
Example
----------
As an example, let's assume that we want to create a 'task_list_engine'.
Ideally we would like to have a TaskList namespace and, for the
databases that support it, a separate task_list schema.
Given that we want to represent the concept of Category in our task
list, we will have a TaskList::Category model, a
askList::CategoryController and a task_list.categories table in our
database (task_list = schema name, categories = table name).
The Problem
----------------
Easy to check:
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 a Rails flaw?
Mauro
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
engine-developers mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org