English 中文(简体)
用户内部未确定的当地变量或方法:
原标题:undefined local variable or method within for User:class

我正在编写一本书,教授自己Ruby-on-Rails。 页: 1

我开始使用废 rub/con,进入:

user = User.new(:screen_name => "example",
?> :email => "exampleATexample.com",
?> :password => "example")

但我没有将数据添加到非行,而是获得以下信息:

NameError: undefined local variable or method  within  for User:Class from D:/ruby/lib/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1235:in  method_missing  from ./script/../config/../config/../app/modules/user.rb:13

我并不真正理解正在发生什么。 非常感谢任何帮助,感谢你!

问题回答

首先,我认为,你的主要铁路公司诉1.2.3号铁路公司,这是一个非常老的铁路,没有使用。

第二,你所进入的指挥机关错了Ruby syntax......而是试图这样做:

user =User.new(:screen_name => "example", :email => "exampleATexample.com", :password => "example")

第三点: 请颁布更多的法典......。

此外,正如检查一样。

无论在铁路做什么,只要与数据库做些什么,确保你经营。

rake db:migrate

有时,这可能lip倒你们的心灵,造成错误。

而且,正如一个方面指出的那样...... 我将确保你在用户模式中添加一些验证,要求用户确认其密码和电子邮件。 它一般是一种良好做法。

validates_confirmation_of :password, :email

最好的是学习铁路。 • 确保你接受@dvyjones的建议,并将之提升到最新铁路版本......自第1.2.3号案以来,已经发生了许多变化。





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签