I''ve fixed it. ActiveRecord, despite my instructions in the
environment.rb file, was still attempting to pluralize the table name. A
quick set_table_name ''content_series'' in the model solved that
problem.
Is this a bug, though? Should ActiveRecord be ignoring my uncountables?
Regards,
Nick Evans
Nicholas Evans wrote:> Howdy,
>
> I have a model I called ''content_series''. I created it
and noticed that
> Rails called it ''Sery'', so I added
''series'' to the uncountable thing in
> the config, like this:
>
> Inflector.inflections do |inflect|
> # inflect.plural /^(ox)$/i, ''\1en''
> # inflect.singular /^(ox)en/i, ''\1''
> # inflect.irregular ''person'',
''people''
> inflect.uncountable %w( series )
> end
>
> Everything seems to work alright except for my tests.
>
> nevans@bell:/var/www2/freepets/test/unit$ ls
> content_series_test.rb content_test.rb user_test.rb
>
> nevans@bell:/var/www2/freepets/test/fixtures$ ls
> content_series.yml contents.yml users.yml
>
> nevans@bell:/var/www2/freepets$ rake test:units
> (in /var/www2/freepets)
> /usr/bin/ruby1.8 -Ilib:test
>
"/usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader.rb"
> "test/unit/user_test.rb" "test/unit/content_test.rb"
> "test/unit/content_series_test.rb"
> Loaded suite
> /usr/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
> Started
> EE.........
> Finished in 0.167462 seconds.
>
> 1) Error:
> test_has_content(ContentSeriesTest):
> ActiveRecord::StatementInvalid: Mysql::Error: Table
> ''freepets_test.content_sery'' doesn''t exist:
SELECT * FROM content_sery
> LIMIT 1
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
> `log''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:185:in
> `execute''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:337:in
> `select''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:176:in
> `select_all''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in
> `find_by_sql''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in
> `find_every''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:918:in
> `find_initial''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:380:in
> `find''
> ./test/unit/content_series_test.rb:12:in `test_has_content''
>
> 2) Error:
> test_series_works(ContentSeriesTest):
> ActiveRecord::StatementInvalid: Mysql::Error: Table
> ''freepets_test.content_sery'' doesn''t exist:
SELECT * FROM content_sery
> LIMIT 1
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
> `log''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:185:in
> `execute''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:337:in
> `select''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:176:in
> `select_all''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in
> `find_by_sql''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in
> `find_every''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:918:in
> `find_initial''
>
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:380:in
> `find''
> ./test/unit/content_series_test.rb:7:in `test_series_works''
>
> 11 tests, 14 assertions, 0 failures, 2 errors
> rake aborted!
>
> Both relevant test lines are ContentSeries.find(:first).
>
> My migrations worked fine, producing a ''content_series''
table. I cannot
> figure out what the problem with my unit test is, though. It''s not
> anything else referencing ''sery'':
>
> nevans@bell:/var/www2/freepets$ grep -Ri sery * | grep -v svn | grep -v log
>
vendor/plugins/acts_as_authenticated/generators/authenticated/templates/index.rhtml:Comrades
> in misery___let me see;
>
> Does anyone know what the issue is?
>
> Thanks,
> Nick Evans
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>