Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoMethodError: undefined method `safe_constantize'

I have a simple model:

class Post < ActiveRecord::Base
end

It has a column INT named type

When I create a record:

Post.create(:type => 1)

I get:

NoMethodError: undefined method `safe_constantize' for 1:Fixnum

What am I doing wrong?

like image 571
0xSina Avatar asked Dec 12 '13 17:12

0xSina


1 Answers

Like it is: There are no method called safe_constantize on a Fixnum.

type is for Single Table Inheritance. You would usually put a string representation of a known model in your application as a type value. See rails guides

like image 62
mathieugagne Avatar answered Oct 18 '22 00:10

mathieugagne