bluesprue
2011-Sep-27 20:04 UTC
Warning: Don''t implement an ActiveRecord model called Specimen
I''ve recently upgraded an application to use Rails 3.1, and in the course of so doing encountered some strange behaviour that I hope will not be experienced by others. I have several ActiveRecord model objects in my application: User, Discussion, Image and Specimen. These all worked absolutely fine in RoR 2.3.8. But in 3.1, Specimen would do nothing but refuse to find its associated database table (''Could not find table "specimen"''), nor would it expose any of its ActiveRecord methods. The other objects (User, Discussion, Image) worked no problem at all. In spite of this, I was able to up, down, change and do all the usual migrations to the Specimen model as expected. The solution was to rename all references in the application from Specimen to Specimn (yes, I know), which put everything back on track. I can find no mention of this word in any reserved word list (http:// oldwiki.rubyonrails.org/rails/pages/ReservedWords, http://wiki.rubyonrails.org/rails/pages/reservedwords#reserved_words_you_can_t_use), nor in the SQLite documentation. Something to watch for, or have I missed something obvious? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Everaldo Gomes
2011-Oct-01 14:47 UTC
Re: Warning: Don''t implement an ActiveRecord model called Specimen
Hi! Search for "inflections" , "rails irregular nouns". http://guides.rubyonrails.org/active_support_core_extensions.html#inflections Best Regards, Everaldo On Tue, Sep 27, 2011 at 5:04 PM, bluesprue <bluesprue-q/Bov5K/xQpeoWH0uzbU5w@public.gmane.org> wrote:> I''ve recently upgraded an application to use Rails 3.1, and in the > course of so doing encountered some strange behaviour that I hope will > not be experienced by others. I have several ActiveRecord model > objects in my application: User, Discussion, Image and Specimen. These > all worked absolutely fine in RoR 2.3.8. But in 3.1, Specimen would do > nothing but refuse to find its associated database table (''Could not > find table "specimen"''), nor would it expose any of its ActiveRecord > methods. The other objects (User, Discussion, Image) worked no problem > at all. In spite of this, I was able to up, down, change and do all > the usual migrations to the Specimen model as expected. The solution > was to rename all references in the application from Specimen to > Specimn (yes, I know), which put everything back on track. I can find > no mention of this word in any reserved word list (http:// > oldwiki.rubyonrails.org/rails/pages/ReservedWords, > > http://wiki.rubyonrails.org/rails/pages/reservedwords#reserved_words_you_can_t_use > ), > nor in the SQLite documentation. Something to watch for, or have I > missed something obvious? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt Jones
2011-Oct-02 14:03 UTC
Re: Warning: Don''t implement an ActiveRecord model called Specimen
On Sep 27, 4:04 pm, bluesprue <bluesp...-q/Bov5K/xQpeoWH0uzbU5w@public.gmane.org> wrote:> I''ve recently upgraded an application to use Rails 3.1, and in the > course of so doing encountered some strange behaviour that I hope will > not be experienced by others. I have several ActiveRecord model > objects in my application: User, Discussion, Image and Specimen. These > all worked absolutely fine in RoR 2.3.8. But in 3.1, Specimen would do > nothing but refuse to find its associated database table (''Could not > find table "specimen"''), nor would it expose any of its ActiveRecord > methods. The other objects (User, Discussion, Image) worked no problem > at all. In spite of this, I was able to up, down, change and do all > the usual migrations to the Specimen model as expected. The solution > was to rename all references in the application from Specimen to > Specimn (yes, I know), which put everything back on track. I can find > no mention of this word in any reserved word list (http:// > oldwiki.rubyonrails.org/rails/pages/ReservedWords,http://wiki.rubyonrails.org/rails/pages/reservedwords#reserved_words_...), > nor in the SQLite documentation. Something to watch for, or have I > missed something obvious?I suspect you''ve got an initializer that added the correct pluralization rule that isn''t getting picked up in 3.1. Out-of-the-box (on both Rails 2 and 3), "specimen" works like this: "specimen".pluralize => "specimen" "specimen".singularize => "speciman" --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2011-Oct-04 13:20 UTC
Re: Warning: Don''t implement an ActiveRecord model called Specimen
Matt Jones wrote in post #1024650:> I suspect you''ve got an initializer that added the correct > pluralization rule that isn''t getting picked up in 3.1. Out-of-the-box > (on both Rails 2 and 3), "specimen" works like this: > > "specimen".pluralize => "specimen" > "specimen".singularize => "speciman"Rails 3.1 (just to clarify): --------- ruby-1.9.2-p290 :003 > "specimen".pluralize => "specimen" ruby-1.9.2-p290 :004 > "specimen".singularize => "speciman" If you wish to use the proper pluralization of "specimen," which is "specimens" you''ll need to add this to your application''s inflections: config/initializers/inflections.rb --------------------------- ActiveSupport::Inflector.inflections do |inflect| inflect.plural ''specimen'', ''specimens'' inflect.singular ''specimens'', ''specimen'' end ----- Loading development environment (Rails 3.1.0) ruby-1.9.2-p290 :001 > "specimen".pluralize => "specimens" ruby-1.9.2-p290 :002 > "specimens".singularize => "specimen" -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.