-
-
Notifications
You must be signed in to change notification settings - Fork 467
Organization
Clearance is a Rails engine but it also asks the developer to include two modules. This is meant for override-ability.
Application controller example:
class ApplicationController < ActionController::Base
include Clearance::Controller
end
User model example:
class User < ActiveRecord::Base
include Clearance::User
end
The generator will also create a migration to add a “users” table and run it. If the table already exists in the database, the migration will just add fields and indexes that are missing and required by Clearance. If the migration fails, the generator will revert all changes back.
Clearance will add these routes:
Users:
get 'users/new'
post 'users'
Confirmations:
get 'users/:user_id/confirmation/new'
post 'users/:user_id/confirmation'
Session:
get 'session/new'
post 'session'
delete 'session'
Passwords:
get 'users/:user_id/password/new'
post 'users/:user_id/password'
get 'users/:user_id/password/edit'
put 'users/:user_id/password'
You will need to display the success, failure, and notice flash messages in your layout. We recommend creating an app/views/layouts/_flashes.html.erb partial similar to the _flashes partial in Suspenders:
<div id="flash">
<% flash.each do |key, value| -%>
<div id="flash_<%= key -%>"><%= html_escape(value) %></div>
<% end -%>
</div>
which is then rendered inside the body tag of your application layout:
<%= render :partial => 'layouts/flashes', :locals => { :flash => flash } -%>
If you need to use a custom layout in any of the clearance controllers, but do not want to override actual controllers, putting them into app/controllers directory you can add
Clearance::SessionsController.layout "custom_clearance_layout"
in your config file.