假设我的Client
模型上有一组属性,如下所示:
# firm_size :float
# priority_level :float
# inflection_point :float
# personal_priority :float
# sales_priority :float
# sales_team_priority :float
# days_since_contact :float
# does_client_vote :float
# did_client_vote_for_us :float
# days_until_next_vote :float
# does_client_vote_ii :float
# did_client_vote_ii_for_us :float
# days_until_vote_ii :float
我需要像这样检查每个属性:
max = Max.find_or_create_by_user_id(:user_id => current_user.id)
if client.firm.size > max.firm_size
max.firm_size = client.firm.size
end
if client.inflection_point > max.inflection_point
max.inflection_point = client.inflection_point
end
其余的属性依此类推,但这对我来说似乎很不干燥。
我如何以优雅的方式做到这一点,而不必if statements
为所有属性输入 10 亿?