每當我試圖運行該rake命令:Ruby有許多關聯錯誤
@user = User.find("1")
@contest = Contest.find("1")
@user.votes.create(:user => self, :contest => @contest)
我得到這個錯誤:
User(#70104671283680) expected, got Object(#70104612331400)
這是我User.rb
has_many :votes
accepts_nested_attributes_for :votes
attr_accessible :votes_attributes
這是我的Contest.rb
has_many :votes
這些都是我的遷移:
change_table :users do |t|
t.references :votes
end
change_table :contests do |t|
t.references :votes
t.references :contest_items
end
change_table :votes do |t|
t.belongs_to :users
t.belongs_to :contests
end
我是否設置正確票?
完蛋了,謝謝! – MichaelScaria 2013-02-22 05:14:32