RoR - 未定义的方法“合并”;
我正在通过 Thimothy Fisher 的《RoR Bible》学习 Ruby on Rails。但其中一个例子不起作用。它的代码 - http://pastebin.com/gtjLsdt0 错误为:Contact#new
中的 NoMethodError
,其中第 4 行引发:
undefined method `merge' for "first_name":String
那是我的 contact_controller。我只是重新输入示例的代码,并且没有任何关于合并的文字
class ContactController < ApplicationController
def index
@contacts = Contact.find(:all);
end
def show
end
def new
@contact = Contact.new;
end
def create
end
def update
end
end
出了什么问题?
I'm studing Ruby on Rails with the "RoR Bible" by Thimothy Fisher. But one of the examples doesn't work. It's code - http://pastebin.com/gtjLsdt0
The error is: NoMethodError
in Contact#new
where line #4 raised:
undefined method `merge' for "first_name":String
that's my contact_controller. I'm just retyping example's code, and there weren't any words about merge
class ContactController < ApplicationController
def index
@contacts = Contact.find(:all);
end
def show
end
def new
@contact = Contact.new;
end
def create
end
def update
end
end
What is wrong??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哈哈,这个例子是完全错误的!
不要这样写:
您应该写
因为通过使用
f.field_type
您将字段分配给提供f
的:contact
表单迭代方法!您也可以编写而不是编写手册!
// 我查了一下你提到的书,它似乎已经过时了。你可以购买“The Rails 3 Way”或其他东西。可以支持当前的 Rails 版本!
Lol that example is completely wrong!
Instead of writing sth like this:
You should write
Because by using
f.field_type
you assign the field to the:contact
form which provides thef
methods by iteration! Also you can writeInstead of writing it manual!
// I loked up the book you refered it seems to be quit outdated. You may buy "The Rails 3 Way" or sth. that can hold up to the current rails version!