Hello,
I''m using singular table names and I''m having some problems
with the
way models are generated. I have
ActiveRecord::Base.pluralize_table_names = false
in config/environment.rb. "script/generate model my_model" produces a
plural test/fixtures/my_models.yml file (which is weird because the
USAGE message for the model generator claims to produce "test fixtures
in test/fixtures/singular_name.yml"). It also produces
test/unit/my_model_test.rb with this code:
fixtures :my_models
def setup
@my_model = MyModel.find(1)
end
I get errors running that unit test because my table name is actually
''my_model'', and the test looks for
''my_models''. So I rename the
fixtures file to test/fixtures/my_model.yml and change the TestCase to
"fixtures :my_model" and get the test to run...
Now the "Hash with Special Powers"
(http://manuals.rubyonrails.com/read/chapter/26) gets written over.
"fixtures :my_model" generates a Fixtures object named @my_model,
which
is overwritten in the setup method...
Is there a way to have the generator produce code that "just works"
with singular table names, without having to edit these files by hand?
I will probably end up using plural table names just to go with the
flow. I''d prefer not to, though, and would rather just have singular
table names work seamlessly with all aspects of Rails. I''d love to
contribute if anyone has ideas or would like to point me in the right
direction.
Big thanks to everyone involved in the Rails project - I''m having a
great time with it...
Zach