RubyGems Navigation menu

easy_rails_authentication 0.0.3


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" if logged_in? %>
<%= render "sessions/login" %>

The `sessions/login` template will automatically detect when a user is logged in and replace the login form with a logout button. The `users/show` template isn't as graceful, so `if logged_in?` is recommended.


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) new_user_path login_path 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:

logged_in? logged_in_as?(user) log_in_as(user) log_out

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.

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. Contant info is in the gemspec file.


  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:


  • Isaac Betesh



Sha 256 checksum:


Total downloads 8,072

For this version 1,099

Show all versions (8 total)

Required Ruby Version: None



= Copy to clipboard Copied!

= Copy to clipboard Copied!