属性「turn_index」を持つ「rota」モデルがあります。何らかの理由で、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