I have 6 fields and I want to set their attributes in model. 3 _print fields are auto saved like this.
def field1=(value)
@number = Phoner::Phone.parse(value)
write_attribute(:field1, @number.to_s)
end
def field1_print=(value)
write_attribute(:field1_print, print_format(@number))
end
And I have these methods for field2, field2_print, field3 and field3_print. Can I put these methods in some .each method and iterate so I don't have these method duplication?
Aucun commentaire:
Enregistrer un commentaire