I have a callback of a model that needs to create a dependent object based on another field entered in the form. But params
is undefined in the callback method. Is there another way to access it? What's the proper way to pass a callback method parameters from a form?
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