In writing an engine, it seems to me that I’d want to put all my model
and controller classes within a namespace, to avoid name clashes with
similarly named classes in the base application, or other engines. By
namespaces, I mean wrap the class in a module.
For example, I’m writing a forum engine, and I have two models.
And I’ve called their tables in the database:
I think this will prevent clashes nicelly, and rails handles it by
creating a /views/forum/ directory for my views. This all works fine
as a rails app, and it runs fine too when I move it into an engine,
except for loading fixtures in tests.
Rails does not have support for looking in a sub directory of
“fixtures”, so i need to call my fixture files:
Then, I do the following in my test case:
fixtures :forum_threads, :forum_comments
set_fixture_class :forum_comments => Forum::Comment
set_fixture_class :forum_threads => Forum::Thread
This works in a normal rails app, but not in an engine. All my tests
do something like this:
FixtureClassNotFound: The class “ForumThread” was not found.
method find in fixtures.rb at line 403
method instantiate_fixtures in testing_extensions.rb at line 86
method instantiate_fixtures in testing_extensions.rb at line 85
method silence in base.rb at line 794
method instantiate_fixtures in testing_extensions.rb at line 84
method instantiate_fixtures in testing_extensions.rb at line 317
method instantiate_fixtures in testing_extensions.rb at line 316
method setup_with_fixtures in fixtures.rb at line 525
method setup in fixtures.rb at line 547
Does anyone know of any difference in the way that namespaces (nested
modules) work in engines compared to normal apps? I’m using rails