我有一个模型的回调,该模型需要根据表单中输入的另一个字段创建依赖对象。但是params
在回调方法中是未定义的。还有其他方法可以访问它吗?从表单传递回调方法参数的正确方法是什么?
class User < ActiveRecord::Base
attr_accessible :name
has_many :enrollments
after_create :create_enrollment_log
private
def create_enrollment_log
enrollments.create!(status: 'signed up', started: params[:sign_up_date])
end
end