I have a user class where I am trying to attach a profile created by a factory. Here is the class:
class User < ActiveRecord::Base
acts_as_authentic
has_one :profile
after_create {self.profile = ProfileFactory.create_profile(self.role)}
end
and the factory is as follows
class ProfileFactory
def self.create_profile(role)
String s = "#{role}#{"Profile"}"
Object.const_get(s).new
end
end
For some reason, he does not recognize himself as a user. This is the error I get when calling ProfileFactory.create_profile
undefined "role" of the method for #<Class:0x2304218>
The user object has the role: String declared in its migration.
Any help is appreciated.
Dave
source
share