https://www.rubydoc.info/gems/tarquinn/0.2.0
This gem makes easier to controll generic redirection
- Add Tarquinn to your
Gemfile
andbundle install
:
gem 'tarquinn'
- Include Tarquinn to your controller or to your base controller
ApplicationController < ActionController::Base
include Tarquinn
end
- Program your redirection on your controllers
BaseController < ApplicationController
redirection_rule :redirect_login, :loggin_needed?
private
def redirect_login
login_path
end
def loggin_needed?
user.nil?
end
end
StaticController < BaseController
skip_redirection_rule :redirect_login, :is_home?
private
def is_home?
params[:action] == 'home'
end
end