Using the omniauth gem, I am forced to define a single route callback for succesful logins, regardless of the provider :
def auth_callback auth_data = request.env['omniauth.auth'] if auth_data.has_key('something') process_one(auth_data) else process_two(auth_data) end # No view is available here end def process_one # do something then render view for process_one return end def process_two # do something then render view for process_two return end
How can I prevent the controller from returning to the auth_callback method and try to display the corresponding view (which does not exist) ? Treatment should be considered as complete once the process_one or process_two methods have returned.
redirect_to is not return Keep in mind that redirect_to does not cause the action to stop executing. It is not like calling return in a Ruby method.
By default, if you use the :plain option, the text is rendered without using the current layout. If you want Rails to put the text into the current layout, you need to add the layout: true option and use the . text. erb extension for the layout file.
Rails Guides describes partials this way: Partial templates - usually just called "partials" - are another device for breaking the rendering process into more manageable chunks. With a partial, you can move the code for rendering a particular piece of a response to its own file.
Rendering is the ultimate goal of your Ruby on Rails application. You render a view, usually . html. erb files, which contain a mix of HMTL & Ruby code.
Why not specifically call render
in those methods?
def process_one # do something then render view for process_one render :process_one and return end
Rails should detect that you've already run it and not try to render again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With