I have a legacy DB I''m using. To make Rails work, I''m explicitly setting primary key names, etc. However, it strikes me that there is consistency in the table naming, just not Rails compliant. I recall seeing ways to tell Rails how to look for table names, column names, etc., and I was wondering if I could save a lot of typing by setting some application level prefs and letting Rails do the work. To wit: - Table names are not pluralized, so the users'' table is named "user". - Primary keys are of the form [Tablename]ID, so the users'' table has a primary key named "UserID". - Foreign keys use the same convention, so the foreign key referencing users in the group table is "UserID". Can any of this be handled with configuration? -- 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 -~----------~----~----~----~------~----~------~--~---
Brian, Try: set_table_name http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000880 and set_primary_key http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000881 Hope that 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your response, Ryan. That''s what I have been doing - what I was hoping for was a way of setting up the environment so that I didn''t have to do that. I think I found some clues here: http://fora.pragprog.com/rails-recipes/write-your-own/post/84 I''ll try it out and see. Ryan wrote:> Brian, > > Try: > > set_table_name > http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000880 > > and > > set_primary_key > http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000881 > > Hope that 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 -~----------~----~----~----~------~----~------~--~---