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命令(47)--scp命令

    scp是secure  copy 的简写,用于在Linux 下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝而不能跨服务器,而且scp传输是加密的.可能会稍微影响一下速度.当 ...

  2. 【转】Python 中 Iterator和Iterable的区别

    Python中 list,truple,str,dict这些都可以被迭代,但他们并不是迭代器.为什么? 因为和迭代器相比有一个很大的不同,list/truple/map/dict这些数据的大小是确定的 ...

  3. Spring_构造注入

    依赖注入的第二种注入方式:构造器注入 创建带参数的构造方法,参数类型为注入类的类型 项目要先添加spring支持: package com; public class Computer { priva ...

  4. java 线程及synchronized关键字

         从本篇开始,我们将会逐渐总结关于java并发这一块的内容,也可以理解为是我的笔记,主要来自于一些博客和java书籍中的内容,所有的内容都是来自于他们之中并且加上了我自己的理解和认识.     ...

  5. spring exception

    Spring MVC异常处理SimpleMappingExceptionResolver[转] (2012-12-07 13:45:33) 转载▼ 标签: 杂谈 分类: 技术分享 Spring3.0中 ...

  6. Java面试系列

    如果你的面试简历是如下这样写的,请务必准备回答下面的所有问题. 面试职位:Java高级工程师 专业技能: (1)牢固掌握Java基础知识,如集合.并发.I/O等,并对Java源码有一定的研究. (2) ...

  7. redux-form的学习笔记

    redux是一种常用的与react框架搭配的一种数据流架构,而伴随着redux的出现,也出现了许多基于redux开源的第三方库,而redux-form就是其中之一的开源组件库,到今天我写下这篇笔记为止 ...

  8. 2243: [SDOI2011]染色

    2243: [SDOI2011]染色 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 3113  Solved: 1204[Submit][Status ...

  9. mybatis 使用场景

    1.Database design is often a separate function (with separate management) from OO domain design 数据库设 ...

  10. 动态规划略有所得 数字三角形(POJ1163)

    在上面的数字三角形中寻找一条从顶部到底边的路径,使得路径上所经过的数字之和最大.路径上的每一步都只能往左下或 右下走.只需要求出这个最大和即可,不必给出具体路径. 三角形的行数大于1小于等于100,数 ...