How to determine what kind of rendering in a controller action

Well, I have a few different ideas about how I achieved this, but I thought I would ask here if someone had a better solution.

I have a SessionController that has a login view and a widget_login view. I was wondering how to determine which view to render in the new SessionController action.

Everything currently uses standard login. I was hoping to be able to display the widget_login view instead if the request came from my reviewcontroller that has a login link. I do not want to use a referrer to determine this, if possible.

thank

+3
source share
2 answers

Not sure if this is possible without seeing your code, but what about something like this:

respond_to do |format|
    format.html { render(:action => 'new') }
    format.widget { render(:action => 'widget_login') }
end

Then in your widget link on new.widget.

+1
source

at the end of the action code:

render :layout => 'my_layout'

if there was already a call render, change it by adding a parameter :layout.

0
source

Source: https://habr.com/ru/post/1763091/


All Articles