У меня есть sessionController, и я пытаюсь добавить метод redirect_back_or в моем session_helper, чтобы разрешить дружественную пересылку.
Вот ошибка, которую я получаю:
undefined method `redirect_back_or' for #<SessionsController:0x007f9fa1b51ec0>
Я перезапустилсервер и не может понять, почему он не находит этот метод в моем помощнике.
Код помощника My Sessions выглядит следующим образом:
module SessionsHelper
def deny_access
store_location
redirect_to signin_path, :notice => "Please sign in to access this page."
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
clear_return_to
end
private
def store_location
session[:return_to] = request.fullpath
end
def clear_return_to
session[:return_to] = nil
end
end
Контроллер моего сеанса
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_back_or user
#redirect_to root_url, :notice => "Signed in!"
end
def destroy
session[:user_id] = nil
redirect_to root_url, :notice => "Signed out!"
end
end