I''m trying to figure out why my database.yml file is adding the letter "s" to the name of my table when doing a query. I tried wiping out my config and starting from scratch using different file names and table names but it does the exact same thing. For instance, my table is named "info", when I try to access info from a web browser, I get a mysql db connection error that says there is no table named "infos". Any idea why this is happening? thanks john --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jakob Skjerning
2006-Dec-31 10:33 UTC
Re: Rails add "s" to end of table name with MySQL DB query
On Dec 20, 2006, at 02:45 , jackster wrote:> I''m trying to figure out why my database.yml file is adding the letter > "s" to the name of my table when doing a query. > > I tried wiping out my config and starting from scratch using different > file names and table names but it does the exact same thing. For > instance, my table is named "info", when I try to access info from a > web browser, I get a mysql db connection error that says there is no > table named "infos". > > Any idea why this is happening?Yes, that''s what ActiveRecord does by default; pluralized table names. You can modify this behaviour easily by adding this to your config/environment.rb: ActiveRecord::Base.pluralize_table_names = false -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RubyGirlUK
2006-Dec-31 18:14 UTC
Re: Rails add "s" to end of table name with MySQL DB query
jackster wrote:> I''m trying to figure out why my database.yml file is adding the letter > "s" to the name of my table when doing a query. > > I tried wiping out my config and starting from scratch using different > file names and table names but it does the exact same thing. For > instance, my table is named "info", when I try to access info from a > web browser, I get a mysql db connection error that says there is no > table named "infos". > > Any idea why this is happening? > > thanks > > johnI think is the way MVC handles the DataBase. Tables map to Classes and by default Active Recird assumes that the name of a table is a plural name of the parallel class. For example Class Shark would become a table name of Sharks. Hope it helps. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Rood
2006-Dec-31 18:51 UTC
Re: Rails add "s" to end of table name with MySQL DB query
Hi Jackster, By default, Rails assumes that a table name is the plural form of the corresponding model name. That assumption can be overridden by uncommenting the line "# ActiveRecord::Base.pluralize_table_names = false" in your config/environment.rb file. If you just want to set an exception for info but pluralize everything else, you can activate and modify the inflect.uncountable statement which also is commented out in that same file. This behavior is described in considerable detail in chapter 14 of the current Pickaxe book. -- Mike -----Original Message----- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of RubyGirlUK Sent: Sunday, December 31, 2006 10:15 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: Rails add "s" to end of table name with MySQL DB query jackster wrote:> I'm trying to figure out why my database.yml file is adding the letter > "s" to the name of my table when doing a query. > > I tried wiping out my config and starting from scratch using different > file names and table names but it does the exact same thing. For > instance, my table is named "info", when I try to access info from a > web browser, I get a mysql db connection error that says there is no > table named "infos". > > Any idea why this is happening? > > thanks > > johnI think is the way MVC handles the DataBase. Tables map to Classes and by default Active Recird assumes that the name of a table is a plural name of the parallel class. For example Class Shark would become a table name of Sharks. Hope it helps. -- 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---