Ruby on rails Michael Hartl指南第6章语法错误用户_spec.rb
我收到以下错误消息:Ruby on rails Michael Hartl指南第6章语法错误用户_spec.rb,ruby-on-rails,Ruby On Rails,我收到以下错误消息: rails_projects/sample_app/spec/models/user_spec.rb:6: syntax error, unexpected ',', expecting ')' @attr = ( :name => "Example User", :email => "user@example.com") 在我设置并仅设置user_spec.rb文件之后 需要“spec\u helper” describe User do before(:
rails_projects/sample_app/spec/models/user_spec.rb:6: syntax error, unexpected ',', expecting ')'
@attr = ( :name => "Example User", :email => "user@example.com")
在我设置并仅设置user_spec.rb文件之后
需要“spec\u helper”
describe User do
before(:each) do
@attr = ( :name => "Example User", :email => "user@example.com")
# pending "add seme examples to (or delete) #{__FILE__}"
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end
it "should require a name"
end
我知道我仍然会在代码处收到一条挂起的消息,但是不是语法错误您需要在此处使用
{…}
作为哈希语法:
@attr = { :name => "Example User", :email => "user@example.com" }
顺便说一句,只是检查了教程-你打错了,不用担心
(本教程中用于代码的字体可能更好!)您需要在此处使用
{…}
作为哈希语法:
@attr = { :name => "Example User", :email => "user@example.com" }
顺便说一句,只是检查了教程-你打错了,不用担心
(本教程中用于代码的字体可能更好!)