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)的更多相关文章

  1. rails undefined method error_messages

    rails undefined method error_messages 学习了:http://stackoverflow.com/questions/10002140/use-error-mess ...

  2. undefined method `environment' for nil:NilClass when importing Bootstrap into rails

    今天做项目时往Gemfile里加了各gem, 然后bundle update了一下, 然后悲剧了,出现了undefined method `environment' for nil:NilClass ...

  3. rails中render 和 redirect_to的区别, each只能用在数组中,如果只有一个或者零个项,用each方法会报错undefined method `each' for #...

    在render中,即使有:action,那么也仅仅是取对应的view中的模板(html.erb)而已,所以这里即使浏览器中的url是/orders/xcreate,但是显示的界面是/app/views ...

  4. ruby on rails错误undefined method `title&#39; for nil:NilClass

    首先搞清楚这句话,在 Ruby 中,方法分为 public.private 和 protected 三种,仅仅有 public 方法才干作为控制器的动作. 我的出错的代码例如以下: controlle ...

  5. 开源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 ...

  6. Xcode同一个Workspace中两个工程依赖于Undefined Symbol Error

    Workspace中包含两个工程A和B: A是dylib工程,引用了另一个动态库C,B需要链接(依赖)A库.当编译B时,会先编译A,然后把A生成的dylib拷贝到B的生成目录中.如果要运行B的话需要把 ...

  7. "undefined method `root' for nil:NilClass" error when using "pod install" 解决办法

    如果pod undate 的时候报错"undefined method `root' for nil:NilClass" error when using "pod in ...

  8. 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 ...

  9. thinkphp报错Call to undefined method app\index\controller\Index::fetch()

    因为要写一个系统,所以又重新下载了thinkphp,然后安装了一下.回忆起这个问题很容易让新手朋友费解.会出现如下报错:Call to undefined method app\index\contr ...

随机推荐

  1. linux 下 zookeeper安装

    1.安装zookeeper-3.4.6cd /usr/soft#解压zookeeper 安装包tar -zvxf zookeeper-3.4.6#拷贝安装包到安装目录cp zookeeper-3.4. ...

  2. 循环神经网络(RNN)模型与前向反向传播算法

    在前面我们讲到了DNN,以及DNN的特例CNN的模型和前向反向传播算法,这些算法都是前向反馈的,模型的输出和模型本身没有关联关系.今天我们就讨论另一类输出和模型间有反馈的神经网络:循环神经网络(Rec ...

  3. ERP免费模拟上线

    为了让更多中小企业在应用管理软件之前可以评估企业执行力和规避实施风险,普实在云端部署了AIO5的试用环境,免费供大家导入实际数据进行学习和测试.因资源有限,申请要求如下: 1.填写申请信息并加盖公章: ...

  4. WCF小试

    1.创建WCF 右键解决方案-新建项目-WCF服务应用程序. 创建后会生成一些文件,其中IService.cs是服务的接口,只有在接口中定义的方法才能被外部调用,Service.svc是我们的服务名称 ...

  5. Jquery的学习:基础核心!

    一.什么是 jQuery jQuery是一个JavaScript库,它通过封装原生的JavaScript函数得到一整套定义好的方法.它的作者是John Resig,于2006年创建的一个开源项目,随着 ...

  6. 队列工厂之(MSMQ)

    最近vs2017神器正式版发布让人很是激动,vs2017支持了很多语言的开发,从前端-后端-底层的支持,堪称是工具中的神器:netcore我喜爱的架构之一也得到了大力的宣传,应群友的邀请将在队列工厂( ...

  7. Vue学习之路---No.4(分享心得,欢迎批评指正)

    这里说声抱歉,周末因为有其他事,没有更新博客,那么我们今天继续上周5的说. 老规矩,先回顾一下上一次的重点: 1.利用V-if和v-else来提到show()和hide(),同时要记住,v-else一 ...

  8. Hibernate打印SQL及附加参数

    今天在项目运行过程中,一直报一个org.hibernate.exception.GenericJDBCException: could not insert 异常,Root Cause是IBM  DB ...

  9. 使用htmlparse爬虫技术爬取电影网页的全部下载链接

    昨天,我们利用webcollector爬虫技术爬取了网易云音乐17万多首歌曲,而且还包括付费的在内,如果时间允许的话,可以获取更多的音乐下来,当然,也有小伙伴留言说这样会降低国人的知识产权保护意识,诚 ...

  10. Mysql5.7服务下载安装

    身处MySQL这个圈子,能够切身地感受到大家对MySQL 5.7的期待和热情,似乎每个人都迫不及待的想要了解.学习和使用MySQL 5.7.那么,我们不禁要问,MySQL 5.7到底做了哪些改进,引入 ...