In my migration, I do this:
["us...@..", "us...@..."].each { |email|
user = User.find_by_email_address(email)
if user
user.update_attributes!(:administrator => true)
end
}
But it dies in HoboFields::ModelExtensions:
undefined method `validate' for "unknown":String
/home/bronson/ws-backend/backend/vendor/plugins/hobo/hobofields/lib/hobo_fields/model_extensions.rb:129:in
`add_validations_for_field'
/home/bronson/ws-backend/backend/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in
`call'
/home/bronson/ws-backend/backend/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in
`evaluate_method'
/home/bronson/ws-backend/backend/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in
`call'
/home/bronson/ws-backend/backend/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in
`run'
/home/bronson/ws-backend/backend/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in
`each'
Apparently record.send(name) is returning a String instead of a
HoboFields::EnumString?!
Anyone have any idea why this would happen? I've included a bit more
info below.
- Scott
Let's check in script/console:
>> User.find(2).gender.class
=> #<EnumString unknown male female>
>> User.find(2).gender.validate
=> nil
It works there! Let's instrument the function and try again:
if type_class && "validate".in?(type_class.public_instance_methods)
self.validate do |record|
print "name=#{name} class=#{record.send(name).class}
record=#{record.inspect}\n"
v = record.send(name)._?.validate # <---- this is where it dies
record.errors.add(name, v) if v.is_a?(String)
end
end
That prints:
name=gender
class=String
record=#<User id: 2, crypted_password: nil, salt: nil, remember_token:
nil, remember_token_expires_at: nil, email_address: "blah",
administrator: true, created_at: "2008-11-05 19:56:57", updated_at:
"2009-01-29 22:55:04", state: "active", key_timestamp: nil>
Bizarre. Should I try to investigate this further?
This is Hobo 0.8.5+ 8e7a67b16912 on sqlite3 running the migration in
development mode.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---