title: ruby rails - redirect to original request url
body: <p>Here is what I have for redirecting to a default url(myapp_url). But I want to change redirect to go the request url was entered by the user after authentication. 
  How do I do that? I tried couple of options from searching here, like :back. But no go. </p>
  
  <p>User enters an url, if not authenticated then gets redirected to the login page, then after login user shall be redirected to the original request url. </p>
  
  <pre><code>def create
     user = User.Authenticate(params[:user_id], params[:password])
   if user
     session[:user_id] = user.id
     redirect_to myapp_url, :notice =&gt; "Logged in!"
  else
      flash.now.alert = "Invalid email or password"
      render "new"
    end
  
  end
  </code></pre>