if statement before_action, - .
class ApplicationController < ActionController::Base
...
before_filter :sending_params
before_action :check_auth, unless: :devise_controller?
...
protected
def check_auth
unless user_signed_in?
redirect_to new_user_session_path(sending_params)
end
end
def sending_params
params.permit(:first_param, :second_param)
end
...
, ,
<%= params[:first_param] %>
params omniauth,
<%= link_to 'Sign in by provider', omniauth_authorize_path(:user, :provider, first_param: params['first_param']) %>
Where: model name for username: provider - supplier name omniauth (: facebook ie)
In omniauth controller you can use
def first_param
request.env['omniauth.params']['first_param'] ||= ''
end
source
share