title: Redirect to previous page following user registration with Rails and Sorcery
body: <p>I have a small Rails 3 app that uses sorcery for User authentication.  When a non authenticated user visits page 'A', they are restricted from viewing portions of the page unless they are logged in or register.</p>
  
  <p>If they select the 'register' link they are taken to a separate Registration page, and on successful registration they are logged in and redirected to the home page.  I need them to be directed back to page 'A'.</p>
  
  <p>This is my User.create controller:</p>
  
  <pre><code>def create
    @user = User.new(params[:user])
    if @user.save
      UserMailer.registration_notification(@user).deliver
      auto_login(@user)
      redirect_back_or_to root_url, :notice =&gt; "Registration successful!  You are now logged in."
    else
      render :action =&gt; :new
    end
  end
  </code></pre>
  
  <p>I'm assuming the <code>redirect_back_or_to</code> bit is where the magic should happen but I'm missing something - currently this just redirects to the home page.  Is there a simple way to do this?  Do I need to pass a current page parameter to the controller or something? </p>