0
我在user_controller中創建了一個實例變量(@edit_id
)update
操作。rails模型使用實例變量
def update
......
@edit_id = 1
......
end
,我有一個活動記錄的回調在user_model
has_many :details
after_update :create_user_details
......
private
def create_user_details
detail = user.details.build
detail.edit_id = @edit_id
#(this @edit_id is the user_controller update action
#created instance variable, but **@edit_id is nil**)
detail.save
end
我如何使用實例變量的回調動作