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
)
精彩评论