I simply want to create another record when the user signs up. I think the following are the only places where Clearance touches my app, not counting the views.
class ApplicationController < ActionController::Base
include Clearance::Controller
before_action :require_login
.
.
.
end
class User < ActiveRecord::Base
include Clearance::User
has_many :received_messages, class_name: 'Message', foreign_key: :receiver_id
has_one :privilege
end
You want
after_create(or perhapsbefore_create, or some other hook, depending on your semantics), which is provided by Rails independent of Clearance. It lets you declare a method to run after yourUserrecord is created, and the method can create other objects that you want to exist.Be aware than
after_createruns in the same transaction as yourUsercreation, so if there's an exception duringOtherThing.create, both it and theUserwill be rolled back.Check out Active Record Callbacks for full details on how ActiveRecord lifecycle hooks work.