Unwanted redirection after authentication

Posted by jodaha on Stack Overflow See other posts from Stack Overflow or by jodaha
Published on 2010-05-12T14:24:37Z Indexed on 2010/05/12 15:04 UTC
Read the original article Hit count: 104

Hello world!

We have a form to submit ratings for a certain restaurant in a in our views/restaurants/show.html.erb. We only want logged in users to create new ratings. We put

before_filter :login_required, :only => [ :new, :create ]

(but we also tried only ":create") on top of our RatingsController. If we click the submit button after typing in the rating details we are prompted to log in (which is what we want). After filling in username and password and submitting the login form we get redirected back to e. g. /restaurants/36/ratings, but we want to be redirected back to where we came from - e. g. /restaurants/36/. We tried redirect_to(:back), but this redirects us back to the login form. Also the new rating does not get saved to the database.

Any idea how we can change the redirection and how to make sure the rating gets saved?

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about restful-authentication