Choosing between devise and clearance
These gems can really help your rails app on user control
Gem names | plataformatec’s_Devise | thoughtbot’s Clearance |
---|---|---|
Summary | MVC/10modules&more extentions | small & simple |
Install | rails generate devise:install | rails generate clearance:install |
rails generate devise MODEL | (create migration for you) | |
other Auth | by OmniAuth | nil |
mailComfirm | bkg ActiveJob/ActionMailer | bkg (deliver_later/ActionMailer) |
PassWdReset | Recoverable&Confirmable | Yes |
Session | cookie Timeoutable&Rememberable | Yes (by Rack session) |
Sign-up | Validatable & Lockable | SignInGuard |
I18n | yes | yes(even path names) |
Track/log | Yes | nil |
testing | Test helpers | yes with factory_girl_rails |
(rails generate clearance:specs) |
Devise
Here is a great tutorial of Devise can be found on Ruby girls. Or you can use Rais Composer to install Devise on a new Rails project by the command rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
. Alternatively, you can install ActiveAdmin gem, which will automatically install Devise for you.
Clearance: Here’s how I setup it
Don’t forget to change local mailing setting if it’s on localhost
Clearance post installation ******************************************************************************* Next steps: 1. Configure the mailer to create full URLs in emails: # config/environments/{development,test}.rb config.action_mailer.default_url_options = { host: 'localhost:3000' } In production it should be your app's domain name. 2. Display user session and flashes. For example, in your application layout: <% if signed_in? %> Signed in as: <%= current_user.email %> <%= button_to 'Sign out', sign_out_path, method: :delete %> <% else %> <%= link_to 'Sign in', sign_in_path %> <% end %><% flash.each do |key, value| %>3. Migrate: rake db:migrate *******************************************************************************<%= value %><% end %>
blog comments powered by Disqus