I have a field in the DB called phone_number , string 10 chars. In
my form i want to make these 3 text boxes (phone1, phone2, phone3). I
am trying to figure out how to assemble this to create the phone
number before saving. I am trying the following:
In the model
before_save :make_phone
def phone1
end
def phone2
end
def phone3
end
def phone1=(p1)
end
def phone2=(p2)
end
def phone3=(p3)
end
def make_phone
self.phone_number = phone1 + phone2 + phon3
end
however i dont seem to have access to params[:model][:phone1] from
here. Any ideas on how to make this work ?
however i dont seem to have access to params[:model][:phone1] from
here. Any ideas on how to make this work ?
Your attribute writer methods don’t do anything at the moment. They’ll
have to set instance variables which can be accessed by the
before_save method. The attr_accessor shortcut can provide these.