This project uses MIT-LICENSE. It’s a standard rails plugin, so you can include it from your application’s Gemfile or your plugin’s gemspec.


The first thing you’ll want to do is migrate your datebase to create its tables, using `rake easy_rails_authentication_engine:install:migrations`.

Then, in your ApplicationController, add these lines:

  include EasyRailsAuthentication::AuthenticationHelper
  before_filter :require_authentication
  before_filter :require_administrator_priveleges

This will guarantee that all your pages can only be accessed by an administrator, but you can, of course, override that in individual controllers using `skip_before_filter …`. See examples in test/dummy/app/controllers/dummy_routes_controller.rb.

A few other basic setup requirements:

  1. Assets: Your application’s javascripts and stylesheets manifests should include the plugin’s appropriate index files using `//= require easy_rails_authentication` (for javascripts) and `*= require easy_rails_authentication` (for stylesheets).

  2. Configure the application’s `config.action_mailer.default_url_options` since the plugin sends e-mails. Do this in config/environments/*.rb or in config/application.rb. Assuming you’ve set MyHost and MyPort to the appropriate values for your domain, configure as follows:

    config.action_mailer.default_url_options = { :host => "#{MyHost}:#{MyPort}" }
  3. Configure some EasyRailsAuthentication configuration parameters, as follows:

    EasyRailsAuthentication.configure do |config|
      config.contact_info = "..." # The way users should contact you with questions about their accounts.  Phone number, email, or both.
      config.send_mail_from = "..." # The email address that this application sends email from
      config.signature = "..." # The last line of all emails.  The name you go by, or "Cheers!" or whatever else you'd like
  4. config/routes.rb must define a root route.

Partial templates

You can include partial templates for logging in an updating user information. In your view or layout:

<%= render "users/show" %>
<%= render "sessions/login" %>

Both of these templates will automatically detect when a user is logged. In that event, the former will not display, and the latter will replace the login form with a logout button.


Running `rake routes` will give you the full picture, but practically speaking, the following paths are the ones you may want to link to:

users_path (index of all users--only admins can view this)
edit_user_path (requires an ID to be passed as an arg)
forgot_password_path (for the user to request an e-mail with a link to reset his password)


`app/helpers/easy_rails_authentication/authentication_helper.rb` defines several functions useful for authentication. The ones you’ll primarily need (in addition to the filters mentioned above) are:


Because these are helper functions, they are accessible from all views and helpers. They should also be accessible from all controllers if you’ve included the helper in your ApplicationController as described above.

When a user is created, the password is initialized to an unusable value. Only by the user following a unique link to set the password can the password be reset so the user can log in. To send the user an email with the link (which is automatically generated when the email is sent):


Similarly, you can send a password recovery email to a user who forgot his password with either of:


These two functions differ in that the former does not send the email if a password recovery is already in progress (i.e. a link has previously been generated and the password has not been reset yet) for that user.

There are also plenty of useful functions in other helper files, so take a look and you may find some code you want to re-use.


The usual github for process. Contact info is in the gemspec file.

installgem install easy_rails_authentication

Isaac Betesh

5,037 total downloads 751 for this version


gem 'easy_rails_authentication', '~> 0.0.8'
  1. 0.0.8 December 6, 2012 (736 KB)
  2. 0.0.7 October 30, 2012 (627 KB)
  3. 0.0.6 October 30, 2012 (99 KB)
  4. 0.0.4 October 11, 2012 (552 KB)
  5. 0.0.3 October 10, 2012 (308 KB)
Show all versions (8 total)
Development Dependencies
  1. sqlite3 >= 0