I quickly ran into problems when trying to create an ActiveRecord instance that reconfigured initialization as follows:
class Email < ActiveRecord::Base
belongs_to :lead
def initialize(email = nil)
self.email = email unless email.nil?
end
end
I found this post that found out why this is happening.
In any case, I can avoid creating the creation code as follows:
e = Email.new
e.email = "info@info.com"
I would like to create and initialize my objects in one line of code.
Is it possible?
source
share