Backo
Backo

Reputation: 18871

Is it possible to name a database table column with the word 'type' without incurring into problems?

I am using Ruby on Rails 3.1.0 and I would like to know if it is possible to name a database table column with the word type without incurring into problems (I know that the "type" word is used in Polymorphic Associations...). Is it?

And if I would like to use, for example, a database table name as article_type, what kind of problems can I have (without using a Polymorphic Association)?

Upvotes: 6

Views: 1770

Answers (1)

Ryan Bigg
Ryan Bigg

Reputation: 107718

Yes it is.

You can use the type column if you define this in your model:

class Model < ActiveRecord::Base
  self.inheritance_column = nil
end

Having a table called article_type wouldn't matter to Rails. It's only the type column that it is protective of.

Upvotes: 15

Related Questions