我不明白为什么我不能在我的partial中使用额外的local。
在父视图中:
<%= render :partial => 'content', :locals => { :post => post, :summary => true } %> 在我的部分中:
<%= summary ? post_content(post, 220) : post_content(post) %>导致错误,其中找不到变量summary:
undefined method `summary?' for #<#<Class:0x007ff425e773b0>:0x007ff425e67a50>有什么想法吗?我可能真的很愚蠢...!!
发布于 2011-10-05 19:10:22
我认为您必须使测试表达式更明确,因为系统正在尝试找到一个名为summary的方法?而不是使用?作为三元运算符。尝试将其更改为:
<%= summary == true ? post_content(post, 220) : post_content(post) %>发布于 2011-10-05 19:22:55
您能否确认在您的部分文件中确实使用了summary <space> ?而不是summary?
发布于 2011-10-05 19:24:43
请仔细阅读错误消息...它说找不到方法summary?,而不是summary。有没有可能您的代码没有在摘要和问号之间包含空格?
https://stackoverflow.com/questions/7660328
复制相似问题