开发者

How to determine which view to render in a controller action

Okay, I have a few different of ideas of how I would achieve this, but thought I would ask here in case someone has a better solution.

I have a SessionsController that has a login view and a widget_login view. I was wondering how to go about determining which view to render in the new actio开发者_如何学JAVAn of SessionsController.

Right now, everything uses the standard login view. I was hoping to be able to render the widget_login view instead if the request is coming from my widget (reviewscontroller) which has a "Sign in" link on it. I don't want to use the referrer to determine this if possible.

Thanks


Not sure if this is feasible without seeing your code, but how 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 to new.widget.


at the end of the action code:

render :layout => 'my_layout'

if there was already a render call, modify it adding the :layout parameter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜