Redirecting without Plugins

I want to be redirected to the current page, after having logged in. I
searched google and only saw ways to do this using certain plugins like
devise.

Isn’t there a simple Way to implement this path?

I start out with

def store_location
session[:return_to] = request.fullpath
end

and I think the only thing left is passing this path to my redirect_ to
code Line in the Sessions Controller, but “redirect_to store_location”
won’t work.

If only Plugins will help, can I use Devise without deleting or
recreating my current User Model?

On Sat, Feb 16, 2013 at 8:52 AM, Ryo S. [email protected] wrote:

end

and I think the only thing left is passing this path to my redirect_ to
code Line in the Sessions Controller, but “redirect_to store_location”
won’t work.

This isn’t doing what you think. You may want to set up something more
akin to accessors:

def store_location=(location)
session[:return_to] = location
end

def store_location
session[:return_to]
end

Then call the first method when you want to save the return page, and
the second when you want to retrieve it.

Thanks. But I think the application still needs something more.

I defined those methods in my application_controller and added to my
“requuire login Method”

def require_login
unless user_signed_in?
redirect_to store_location=(request.fullpath)
redirect_to login_path,
alert: “Erst anmelden bitte!”
end
end

and added to my create method in the sessionscontroller:

def create
user = User.find_by_username(params[:username])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
#redirect_to startscreen_path,
redirect_to store_location,
notice: “logged in”

When I now want to retrieve a page, that has the befor_filter “require
login”
I get the Error Message.

AbstractController::DoubleRenderError in GamesController#new

Render and/or redirect were called multiple times in this action. Please
note that you may only call render OR redirect, and at most once per
action. Also note that neither redirect nor render terminate execution
of the action, so if you want to exit an action after redirecting, you
need to do something like “redirect_to(…) and return”.

When logging in directly (without filters), I get the Error Message
ActionController::ActionControllerError in SessionsController#create

Cannot redirect to nil!