开发者

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

开发者 https://www.devze.com 2023-02-15 12:56 出处:网络
In my seeds.rb file I have: user = User.new( :user_type => UserTypes.MEMB开发者_如何学GoER ) I get an error:

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

精彩评论

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