私は、属性 "turn_index"を持つ "rota"モデルを持っています。何らかの理由で、update_attributesが機能していないようです。任意の手掛かりはなぜですか?Rails:単純なupdate_attributesが動作しない
rota = Rota.create
rota.turn_index.should == 0 -- passes
rota.update_attributes(:turn_index=>1)
rota.turn_index.should == 1 -- fails
ロタのスキーマは次のとおりです。
create_table "rotas", :force => true do |t|
t.string "name"
t.integer "turn_index"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
ロタモデル:
class Rota < ActiveRecord::Base
has_many :rotazations
has_many :users, :through => :rotazations
has_many :invitations
before_save :set_turn_index
private
def set_turn_index
self.turn_index = 0
end
end
ロータモデルはどのように見えますか? – natedavisolds
更新された質問 – Karan