I'm trying to make attributes equal predetermined values, and I'm not sure if I'm doing that efficiently with the following (in my orders controller):
def create
@order = Order.find(params[:id])
@order.price = 5.99
@order.representative = Product.find(params[:product_id]).representative
@order.shipping_location = SHIPPING_LOCATION
@order.user = current_user
respond_to do |format|
...
end
end
Is there a more efficient way to equate attributes in Rails (maybe using models)? If I'm using two different controllers, do I just repeat what I did above for the new controller?