如果满足某些条件,我在控制器中有一些逻辑可以设置对象的状态:
if params[:concept][:consulted_legal] == 0 && params[:concept][:consulted_marketing] == 1
@concept.attributes = {:status => 'Awaiting Compliance Approval'}
elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_legal] == 1
@concept.attributes = {:status => 'Awaiting Marketing Approval'}
elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_legal] == 0
@concept.attributes = {:status => 'Awaiting Marketing & Legal Approval'}
else
@concept.attributes = {:status => 'Pending Approval'}
end
我在创建和更新操作之间共享。你将如何重构这种肮脏的东西?寻找最佳实践。
编程新手,热衷于清理我的代码。
TIA。