ruby on rails - undefined local variable or method <object> for #<Class:0x55ebe50> -
i have problems polymorphic in rails.
i have files:
class createexecutions < activerecord::migration def change create_table :executions |t| t.integer :player_space_id t.integer :what_id t.references :what, polymorphic: true t.integer :qty t.integer :level t.datetime :when_ready t.timestamps end end end class execution < activerecord::base belongs_to :what, :polymorphic => true end class element < activerecord::base belongs_to :game_space has_many :levels has_many :player_elements has_many :executions, :as => end class playerspace < activerecord::base belongs_to :game_space belongs_to :user has_many :executions, as: :what end and when run controller has element, have error:
nameerror in playerspacescontroller#show undefined local variable or method `what' #
may me
you have slight typo in element class: change this:
class element < activerecord::base #... has_many :executions, :as => end to this:
class element < activerecord::base #... has_many :executions, :as => :what end e.g missing colon 'what' means it's not symbol , instead variable or method. don't have variable or method named what, ruby throwing 'unnamed variable or method' error.
Comments
Post a Comment