Use “error_messages” in Rails 3.2? (raises “undefined method” error)
I am getting the following error in my Rails 3.2 functional tests:
ActionView::Template::Error: undefined method `error_messages' for # <ActionView::Helpers::FormBuilder:0x007ff8ad00d3b0>
The view code that is creating the error:
<%= form_for [@camp,@program]do|f|%><%= f.error_messages %># problematic code<%= f.label :name %><%end%>
Here is the code in my controller that is calling the above view code:
render :action =>"edit",:status =>:bad_request
And here is the test I am running:
test "update a program with a bad request"do
put :update,:id => programs(:traditional).to_param,:program =>{:min_age =>"a"},:camp_id => camps(123).uri
assert_response :bad_request
end
正确解决方法: <%= form_for [@camp,@program]do|f|%><%@program.errors.full_messages.each do|msg|%><p><%= msg %></p><%end%><%= f.label :name %><%end%>
参考路径:http://stackoverflow.com/questions/10002140/use-error-messages-in-rails-3-2-raises-undefined-method-error
Use “error_messages” in Rails 3.2? (raises “undefined method” error)的更多相关文章
- rails undefined method error_messages
rails undefined method error_messages 学习了:http://stackoverflow.com/questions/10002140/use-error-mess ...
- undefined method `environment' for nil:NilClass when importing Bootstrap into rails
今天做项目时往Gemfile里加了各gem, 然后bundle update了一下, 然后悲剧了,出现了undefined method `environment' for nil:NilClass ...
- rails中render 和 redirect_to的区别, each只能用在数组中,如果只有一个或者零个项,用each方法会报错undefined method `each' for #...
在render中,即使有:action,那么也仅仅是取对应的view中的模板(html.erb)而已,所以这里即使浏览器中的url是/orders/xcreate,但是显示的界面是/app/views ...
- ruby on rails错误undefined method `title' for nil:NilClass
首先搞清楚这句话,在 Ruby 中,方法分为 public.private 和 protected 三种,仅仅有 public 方法才干作为控制器的动作. 我的出错的代码例如以下: controlle ...
- 开源IDS系列--snorby 2.6.2 undefined method `run_daily_report' for Event:Class (NoMethodError)
rails runner "Event.run_daily_report"测试邮件配置undefined method `run_daily_report' for Event:C ...
- Xcode同一个Workspace中两个工程依赖于Undefined Symbol Error
Workspace中包含两个工程A和B: A是dylib工程,引用了另一个动态库C,B需要链接(依赖)A库.当编译B时,会先编译A,然后把A生成的dylib拷贝到B的生成目录中.如果要运行B的话需要把 ...
- "undefined method `root' for nil:NilClass" error when using "pod install" 解决办法
如果pod undate 的时候报错"undefined method `root' for nil:NilClass" error when using "pod in ...
- gitlab ActionView::Template::Error (undefined method `[]' for nil:NilClass): 500错误
Started GET "/mygroup/myproject/tree/master/MyDirectory" for 127.0.0.1 at 2014-10-22 22:42 ...
- thinkphp报错Call to undefined method app\index\controller\Index::fetch()
因为要写一个系统,所以又重新下载了thinkphp,然后安装了一下.回忆起这个问题很容易让新手朋友费解.会出现如下报错:Call to undefined method app\index\contr ...
随机推荐
- 每天一个Linux命令(02)--cd命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句都要进行操作,都是建立在使用 cd命令基础上的. 所以,学习Linux常用命令,首先就要学好 cd 命令的使用技巧. 1.命令 ...
- php根据用户输入单词,匹配相似单词
最近在使用一款app背单词的时候,会在某个单词下面,列出与之相类似的单词.于是我在想这个功能是如何做的,自己使用php版本,做了个简单的例子. 大致思路如下: 1.生成英文单词库,并将单词放置redi ...
- 数据的增删改查(三层)<!--待补充-->
进行数据操作必然少了对数据的增删改查,用代码生成器生成的代码不是那么满意!方便在今后使用,这里就主要写“数据访问层(Dal)” 既然这里提到三层架构:有必要将三层内容在这里详细介绍一下(待补充) 注: ...
- 关于Edittext默认弹出软键盘为数字键
如果说我们只是输入数字的话,我们可以直接在xml文件中: android:inputType="number" 如果是身份证类型的话,我们可以这样: android:inputTy ...
- App Store 审核 IPv6 问题
应用提交了N次,每次被拒都是说IPv6的事情,花点功夫把这个事情搞清楚. 苹果审核人员回复的原因都差不多,说在他们的IPv6-Only的环境中测试应用,无法正常请求我们的服务器. 因为我们的域名确实没 ...
- Instant App 即将到来,Android 集权或将加速分裂
在境外,Android 的体验将越来越好,在中国,Android 的更新可能将止步于6.0! 话题讨论:Instant App 在中国将何去何从? 以下为谷歌原创文章 2017-03-03 Googl ...
- .Net程序员学用Oracle系列(22):分析函数(OVER)
1.函数语法 1.1.语法概述 1.2.窗口详解 1.2.1.ROWS 窗口 1.2.2.RANGE 窗口 2.函数用法 2.1.普通统计类函数 2.2.数据排序类函数 2.3.数据分布类函数 2.4 ...
- 读书笔记 effective c++ Item 35 考虑虚函数的替代者
1. 突破思维——不要将思维限定在面向对象方法上 你正在制作一个视频游戏,你正在为游戏中的人物设计一个类继承体系.你的游戏处在农耕时代,人类很容易受伤或者说健康度降低.因此你决定为其提供一个成员函数, ...
- 在Windows的DOS中运行java编程中的问题
1.苦恼着我的就是找不到或无法加载主类!
- webkit图片滤镜
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...