types - Rails Single table inheritance problem -
I set up a single table heritage in my rail app for a user model and its subclass members, subscribers, and staff I am trying.
I have a model file for each: user.rb, member.rb, etc.
User model is defined: class user & lt; ActiveRecord :: Base; the ending;
I subclassed other models like this: class members & lt; the user; In the end;
and so on.
In my user table, I need every square plus type field now when I go to the console and try to try to create a new example, the member or customer receives the following error:
I have read the simple document, but should I remember something? I tried to start with a scratch app and it works Here is my user model (User.rb) My Member Model (Member .rb) is a migration file for creating my user table: Now launch the console: However, I did not manage to reproduce your error: ( TypeError: NilClass / Library / Ruby / Gem / 1.8 / Gems / Active Records -2.3.4 / lib / active_record / base.rb: 2184: / 'Library / Rabby / Games / 1.8 / Game / Actylactor-2.3.3 / Lib / Active_Record / Base. In 'Dup' with RB: 2184: / Library / Rabi / Games / 1.8 / Games / Action Special to Family-2.3.3 / Lib / Active_Record / Base RB 1818: 'Active_screens_sms' ActiveContact- 2.3.4 / lib / active_record / base.rb: 2171: 'In Scod?' In 'ScoredMethane' in / from / Script / Theme / 1/8 / Games / From / Library / Rabbi / Games / 1.8 / Games / Active Record -2.3.4 / Lib / Active_Record / Base In 'Initialize' from (RBB) in 'Libre / active_record / base.rb: 2439:' from 'Library / Ruby / Games / 1.8 / Games / Actitized-2.4.3' in RBI 2439: In '6: New '(IRB): 6 Railways know that the sub-class models are in the console when I only call the subscriber or the subscriber, then the class definition is returned to me.
class user & lt; ActiveRecord :: Base End
class members & lt; At the end of the user
class CreateUsers & lt; ActiveRecord :: Migration DF self.up create_table: users do | T | T.string: Name t.timestamps end end def self.down drop_table: User End End
➜ ./script/ Console Loading Evolution Environment (Rail 2.3.4) & gt; & Gt; U = user.new = & gt; # & Lt; User ID: Zero, Name: Zero, Created_AT: Zero, Updated: Zero & gt; & Gt; & Gt; I = Members.New => # & Lt; Member ID: Zero, Name: Zero, Created_AT: Zero, Updated: Zero & gt; & Gt; & Gt; M.name = "hop" = & gt; "Hop" & gt; & Gt; M.save = & gt; True
Comments
Post a Comment