如何确定在控制器操作中渲染哪个视图
好吧,我对如何实现这一目标有一些不同的想法,但我想我会在这里问,以防有人有更好的解决方案。
我有一个 SessionsController,它有一个登录视图和一个 widget_login 视图。我想知道如何确定在 SessionsController 的新操作中呈现哪个视图。
现在,一切都使用标准登录视图。如果请求来自我的小部件(reviewscontroller),它上面有一个“登录”链接,我希望能够渲染 widget_login 视图。如果可能的话,我不想使用引荐来源网址来确定这一点。
谢谢
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 action 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在没有看到您的代码的情况下不确定这是否可行,但是像这样的事情怎么样:
然后在您的小部件中链接到
new.widget
。Not sure if this is feasible without seeing your code, but how about something like this:
Then in your widget link to
new.widget
.在操作代码末尾:
如果已经存在
render
调用,请修改它并添加:layout
参数。at the end of the action code:
if there was already a
render
call, modify it adding the:layout
parameter.