SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rails database table naming conventions

    Hi,
    Im am just picking up Rails, so please excuse any ignorance on my part.
    So far from what I have read, I like the looks of Rails as it pretty much follows the conventions I use in my php developement, but handles it all for me quite nicely. The only thing I would like to change is the way Rails handles database table naming conventions. I would rather stick with the singular form for both classes and db tables, rahter than singular for the classes, and plural for the db.

    I know I can change/modify the inflection rules in the environment.rb config file, but will changing the standard naming convnetion for the db tables lead to any problems for me down the road?

    Ie If I were to set the inflection rules in the environment.rb config file to
    Code:
    Inflector.inflections do |inflect|
       inflect.plural /^(.*)$/i, '\1'
       inflect.singular /^(.*)$/i, '\1'
       inflect.irregular '', ''
    if this going to hurt be down the road?

    Thanks in advance

    Mike

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    That's not where you should make this change, but you did find the right file at least

    in environment.rb:
    Code:
    Rails::Initializer.run do |config|
      # Settings in config/environments/* take precedence those specified here
      
      config.active_record.pluralize_table_names = false
    end
    Then you can use singular tables without too much of a penalty.

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice, thankyou very much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •