With Currentuser.io, adding user management capabilities to your Ruby on Rails application is very simple.

  1. Sign up to Currentuser.io, create a new project and retrieve Project ID from the Currentuser.io settings.

  2. Add the currentuser-services gem in the Gemfile of your application:

    # Gemfile
    gem 'currentuser-services'
  3. Create an initializer:

    # config/initializers/currentuser.rb
    Currentuser::Services.configure do |config|
      # Replace 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with your Project ID
      config.project_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
  4. Mount the Currentuser engine:

    # config/routes.rb
    MyApplication::Application.routes.draw do
  5. Protect your actions:

    # app/controllers/application_controller.rb
    class ApplicationController < ActionController::Base
      before_action :require_currentuser


Your application is now protected: visitors need to sign up and sign in to access it. You can call currentuser_id in any action (or view) to identify the person currently using your application.

More info in Registration, Authentication and Administration sections.