Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

  • Blog Navigation
Upgrading to Rails 3.0.5 inflections

We’re working on an upgrade form 3.0.4 and we got a database error when we tried to generate fixtures or seed the db:

PGError: ERROR:  relation "data" does not exist
LINE 4:              WHERE a.attrelid = '"metadata"'::regclass

We first ran into this with a has_one :metadata association but you’d have the same problem without any associations to the Metadata class. Investigation lead to this discovery:

rails-3.0.4 > Metadata.table_name
=> "metadatas"
rails-3.0.5 > Metadata.table_name
=> "metadata"

The rails team added some inflections to ActiveSupport::Inflector and fixed a scaffold generator.

This fixed double-pluralization of irregular plurals for ticket 6363.

Example:

rails-3.0.4 > ActiveSupport::Inflector.pluralize "metadata"
=> "metadatas"
rails-3.0.5 > ActiveSupport::Inflector.pluralize "metadata"
=> "metadata"

Here are example of the four changed nouns:

  • data: “datas” is now “data”
  • viri : “viris” is now “viri”
  • oxen: “oxens” is now “oxen”
  • mice: “mices” is now “mice”

Anyway, quick fix:

class Metadata < ActiveRecord::Base
  set_table_name "metadatas"
end

Of course, we could rename our metadata class and table…

Thanks to this guy for pointing this out!

Comments
  1. Sam Figueroa says:

    Thanks for sharing this Rachel.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *

Share This