渲染中的传递参数-Rails 3 [英] Pass Parameters in render - Rails 3

查看:86
本文介绍了渲染中的传递参数-Rails 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了几个问题,但是还无法解决...

I've seen a couple questions on this but haven't been able to solve it...

我正在尝试在渲染部分参数时传递参数(类似于domainname.com/memory_books/new?fbookupload=yes)

I'm trying to pass a parameter while rendering a partial (similar to domainname.com/memory_books/new?fbookupload=yes)

现在,我使用此行:

<%= render :partial => '/memory_books/new', :fbookupload => "yes" %>

在部分内容中,我尝试使用以下方法获取fbookupload的内容:

and in the partial, I have tried to get the content of fbookupload by using:

<%= fbookupload %>

给出未定义的局部变量"错误,并且

which gives an "undefined local variable" error and

<%= params.inspect %>

不将fbookupload显示为参数.

which does not show fbookupload as a parameter.

如何部分传递参数:fbookupload?

How can I have the partial pass along the parameter :fbookupload?

谢谢.

更新:

这与我在渲染器中渲染它有关吗?

Could it have anything to do with the fact that I'm rendering this within a render?

即具有

<%= render :partial => '/memory_books/new', :fbookupload => "yes" %>

由另一个页面通过(帖子/显示)通过以下方式呈现:

is being rendered by another page with (posts/show) via:

<%= render :partial => '/fbookphotos/show' %>

所以我要在渲染器中渲染它.

so I'm rendering this within a render.

推荐答案

尝试一下:

<%= render :partial => '/memory_books/new', :locals => {:fbookupload => "yes"} %>

这篇关于渲染中的传递参数-Rails 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆