I used “type” as a column in “rails generate model” there was no error.
I did a rake db:migrate again no problem.
I created the values using console again no problem.
I did a show function in users contoller then rails threw up the error.
should it not give this error right at the time of generate
model or db:migrate or atleast create.
ActiveRecord::SubclassNotFound in UsersController#show
The single-table inheritance mechanism failed to locate the subclass:
‘student’. This error is raised because the column ‘type’ is reserved
storing the class in case of inheritance. Please rename this column if
you didn’t intend it to be used for storing the inheritance class or
User.inheritance_column to use another column for that information.
It won’t be instantiating any model objects at that point. Besides, it’s
completely legal to create a model with a column called type, it’s just
that activerecord makes assumptions about what is going to be in that
Not unless you’ve written some code in the migration to do so.
Is there anything like a cheat sheet for rails ?
There certainly are things like cheatsheets for Rails. I gave you a
link already to one reference, which had other links in it
(specifically, to the Rails wiki, which does not seem to be responding
at the moment), but if you Google your phrase “cheat sheet for rails”
you will get lots of results.
Actually I found one but that did not have “type” as a reserved word.
Trust us, it is… you’ve discovered that yourself already
Rails uses it to determine STI class type. Just change your fieldname
for now, and all will be good.
You application crashed because you probably have a user of type
“student” but you don’t have a matching class for it. As others
explained the migrations and model generations don’t use single table
inheritance, so they won’t crash on it. Furthermore the generators don’t
know which types you want to use in your application, you have to create
these manually as new models