How to write this Ruby function using a loop? -
is there more elegant way write in ruby, maybe using loop?
def save_related_info update_column(:sender_company_name, user.preference.company_name) update_column(:sender_address, user.preference.address) update_column(:sender_telephone, user.preference.telephone) update_column(:sender_email, user.preference.email) update_column(:sender_url, user.preference.url) update_column(:sender_vat_number, user.preference.vat_number) update_column(:sender_payment_details, user.preference.payment_details) end
thanks help.
def save_related_info %w[company_name address telephone email url vat_number payment_details] .each{|s| update_column("sender_#{s}".to_sym, user.preference.send(s))} end
Comments
Post a Comment