line_items というモデルがあります。価格フィールドが含まれています。ユーザーが価格を入力すると、それは foodio_price または delivery_price になります。そして、価格フィールドにはそのような値がたくさんあります。
これにチェックを入れたい。これが私の状態です:
price フィールドのすべての価格は、foodio_price または delivery_price である必要があります。そうでない場合はエラーを返し、ある場合は foodio_price か delivery_price かを示します。
誰もそれを実装するのを助けることができますか?
私はうまくいかない非常に汚いことをしました:
@line_items.each do |i|
if i.price == i.product.foodio_price
@line_items.each do |i|
if i.price == i.product.delivery_price
render :action => "cart"
end
end
else
@line_items.each do |i|
if i.price == i.product.foodio_price
render :action => "cart"
end
end
end
end
レンダリングまたはリダイレクトの呼び出しが多すぎるというエラーが発生します