0
我在Rails中遇到了多態性問題。未定義的局部變量或方法<object> for#<Class:0x55ebe50>
我有這樣的文件:
class CreateExecutions < ActiveRecord::Migration
def change
create_table :executions do |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 => what
end
class PlayerSpace < ActiveRecord::Base
belongs_to :game_space
belongs_to :user
has_many :executions, as: :what
end
當我運行的具有元件的控制器,我有這樣的錯誤:
NameError在PlayerSpacesController#顯示 未定義的局部變量或方法'什麼」爲#
願你幫我