Bhasker Harihara
2011-Feb-22 06:15 UTC
Is this a bug in ActiveRecord or expected to work this way ??
Hi, 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. But 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 for 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 overwrite User.inheritance_column to use another column for that information. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2011-Feb-22 06:49 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
On 22 February 2011 06:15, Bhasker Harihara <harihara.bhasker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I used "type" as a column in "rails generate model" there was no error. > > ActiveRecord::SubclassNotFound in UsersController#show"Type" is a reserved word in Rails (the wiki seems to be not responding, but there''s still a few references around): http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/> I did a show function in users contoller then rails threw up the error. But > should it not give this error right at the time of generate > model or db:migrate or atleast create.At neither of those times is ActiveRecord doing anything with the model (unless you''re accessing your model in your migration...) so it wouldn''t cause an error until you try to instanciate an object. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bhasker Harihara
2011-Feb-22 06:57 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
Hi, Is it not accessing the model at the time of $rake db:migrate. Is there anything like a cheat sheet for rails ? Actually I found one but that did not have "type" as a reserved word. Regards, On Tue, Feb 22, 2011 at 12:19 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 February 2011 06:15, Bhasker Harihara <harihara.bhasker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Hi, > > > > I used "type" as a column in "rails generate model" there was no error. > > > > ActiveRecord::SubclassNotFound in UsersController#show > > "Type" is a reserved word in Rails (the wiki seems to be not > responding, but there''s still a few references around): > > http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/ > > > I did a show function in users contoller then rails threw up the error. > But > > should it not give this error right at the time of generate > > model or db:migrate or atleast create. > > At neither of those times is ActiveRecord doing anything with the > model (unless you''re accessing your model in your migration...) so it > wouldn''t cause an error until you try to instanciate an object. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-Feb-22 07:58 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
On 22 Feb 2011, at 06:57, Bhasker Harihara <harihara.bhasker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > Is it not accessing the model at the time of > > $rake db:migrate. >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 column Fred> Is there anything like a cheat sheet for rails ? > > Actually I found one but that did not have "type" as a reserved word. > > Regards, > > On Tue, Feb 22, 2011 at 12:19 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > On 22 February 2011 06:15, Bhasker Harihara <harihara.bhasker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > > > I used "type" as a column in "rails generate model" there was no error. > > > > ActiveRecord::SubclassNotFound in UsersController#show > > "Type" is a reserved word in Rails (the wiki seems to be not > responding, but there''s still a few references around): > > http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/ > > > I did a show function in users contoller then rails threw up the error. But > > should it not give this error right at the time of generate > > model or db:migrate or atleast create. > > At neither of those times is ActiveRecord doing anything with the > model (unless you''re accessing your model in your migration...) so it > wouldn''t cause an error until you try to instanciate an object. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2011-Feb-22 08:24 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
On 22 February 2011 06:57, Bhasker Harihara <harihara.bhasker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is it not accessing the model at the time of > > $rake db:migrate.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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bhasker Harihara
2011-Feb-22 09:45 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
I did not see the other links in the main link. I have changed already. But I wanted the link to avoid such mistakes in the future. Thanks & Regards, On Tue, Feb 22, 2011 at 1:54 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 February 2011 06:57, Bhasker Harihara <harihara.bhasker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Is it not accessing the model at the time of > > > > $rake db:migrate. > > 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 received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Mark Kremer
2011-Feb-24 05:24 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
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 If you look at the ActiveRecord::Base API documentation (http://api.rubyonrails.org/classes/ActiveRecord/Base.html) and scroll down to the section on "Single Table Inheritance" you''ll see what single table inheritance is about. If you want to know more about Rails'' API then you can find all of the API documentation for Rails here: http://api.rubyonrails.org/ You can also get some valuable information from the Rails Guides too: http://guides.rubyonrails.org/ On 22-2-2011 7:15, Bhasker Harihara wrote:> Hi, > > 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. But 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 for > 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 overwrite > > User.inheritance_column to use another column for that information. > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bhasker Harihara
2011-Feb-24 06:32 UTC
Re: Is this a bug in ActiveRecord or expected to work this way ??
Hi Mark, Thanks, yeah latter I saw that. On Thu, Feb 24, 2011 at 10:54 AM, Mark Kremer <mark-35I9eEnyf3ce/i+EH++dVqxOck334EZe@public.gmane.org>wrote:> 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 > > If you look at the ActiveRecord::Base API documentation ( > http://api.rubyonrails.org/classes/ActiveRecord/Base.html) and scroll down > to the section on "Single Table Inheritance" you''ll see what single table > inheritance is about. > > If you want to know more about Rails'' API then you can find all of the API > documentation for Rails here: http://api.rubyonrails.org/ > You can also get some valuable information from the Rails Guides too: > http://guides.rubyonrails.org/ > > > On 22-2-2011 7:15, Bhasker Harihara wrote: > > Hi, > > 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. > But 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 for > 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 overwrite > > User.inheritance_column to use another column for that information. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.