Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 977
Backo Avatar asked Jan 04 '12 06:01

Backo


1 Answers

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.

like image 124
Ryan Bigg Avatar answered Oct 16 '22 01:10

Ryan Bigg