Redirect on catching an exception in a method in the model
Posted
by
Arkid
on Stack Overflow
See other posts from Stack Overflow
or by Arkid
Published on 2010-12-26T21:33:04Z
Indexed on
2010/12/26
21:53 UTC
Read the original article
Hit count: 196
I am using Authlogic-connect to connect various service providers. There is a method in user.rb
def complete_oauth_transaction
token = token_class.new(oauth_token_and_secret)
old_token = token_class.find_by_key_or_token(token.key, token.token)
token = old_token if old_token
if has_token?(oauth_provider)
self.errors.add(:tokens, "you have already created an account using your #{token_class.service_name} account, so it")
else
self.access_tokens << token
end
end
When a service provider is already added it gives the error as stated in the has_token? method and the page breaks. I need to redirect the app to the same page and flash the error. How do i do this? I have overridden the method in my own user.rb so that I can change the code.
© Stack Overflow or respective owner