i have 2 models:
class user < activerecord::base has_one :client end class client < activerecord::base belongs_to :user end
and create user
first, , have after_create
filter, create client
after user
has been created.
after_create :create_client
i have new case client
exists, , want create user
after client
exists. in case, when create user
i'd skip after_create
filter.
i understand i'll need after_create :create_client, unless: ____
i'm not sure how distinguish this.
for case can create instance variable using attr_accessor
class user < activerecord::base attr_accessor :has_client ... end
and can assign boolean value variable , restrict after_create if condition
class user < activerecord::base ... after_create :create_client, unless: :has_client ... end
Comments
Post a Comment