当我在coffeescript交互模式下键入多行时,出现错误.
为了exacmle,我想尝试以下代码.
kids =
brother:
name: "Max"
age: 11
sister:
name: "Ida"
age: 9
Run Code Online (Sandbox Code Playgroud)
显示此错误.
coffee> kids =
Error: In repl, Parse error on line 1: Unexpected 'TERMINATOR'
at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
at /usr/lib/coffeescript/coffee-script.js:26:22
at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
at Interface.emit (events:27:15)
at Interface._ttyWrite (readline:309:12)
at Interface.write (readline:147:30)
at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
at Stream.emit (events:27:15)
Run Code Online (Sandbox Code Playgroud)
我尝试使用'\'作为换行符,但显示了相同的错误.
coffee> kids = \
Error: In repl, Parse error on line 1: Unexpected '\'
at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
at /usr/lib/coffeescript/coffee-script.js:26:22 …Run Code Online (Sandbox Code Playgroud) 我想定义Fabricator for class有'Foo :: Bar'这样的命名空间.
告诉我它的工作方式.
在这里我的代码.
车型/ foo.rb
class Foo
include Mongoid::Document
embedded_in :foo_container, polymorphic: true
field :xxx ....
end
Run Code Online (Sandbox Code Playgroud)
车型/富/ bar.rb
class Foo::Bar < Foo
field :yyy ....
field :zzz ....
end
Run Code Online (Sandbox Code Playgroud)
数据/制造者/ foo_bar_fabricator.rb
Fabricator(:foo_bar, class_name: 'Foo::Bar') do
yyy 'MyString'
zzz 'MyString'
end
Run Code Online (Sandbox Code Playgroud)
当我尝试在parino控制台上创建Fabricatior对象但发生错误.
> Fabricate(:foo_bar)
> NoMethodError: undefined method `new?' for nil:NilClass
.... stack messages
Run Code Online (Sandbox Code Playgroud)
当我尝试创建其他Fabricator对象时不是像'User'这样的命名空间类,它就是正确的.