开发者

Rake aborted, I think it is in reference to a enum I have in my /lib folder

In my seeds.rb file I have:

user = User.new(
   :user_type => UserTypes.MEMB开发者_如何学GoER

)

I get an error:

rake aborted!
Expected /..../lib/user_types.rb to define UserTypes


module SomeName

   class UserTypes
       MEMBER = 1,
       BLAHBALH = 2
   end

end

Do I need an include or require at the top of the file?


Not an include, you need the full classname (incl. modules). You might also need to move the file to lib/some_name/user_types.rb (this you can avoid by using an explicit require).

user = User.new(
   :user_type => SomeName::UserTypes::MEMBER
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜