Rails: Check value in an array -


i have model, called line_items. contains price field. when user enters price, can foodio_price or delivery_price. , price field has lot of such values.

i want put check on this. here condition:

all prices in price field should foodio_price or delivery_price. if not, give error , if yes, give whether foodio_price or delivery_price.

can in implementing it?

i did quite dirty not working:

       @line_items.each |i|           if i.price == i.product.foodio_price               @line_items.each |i|                 if i.price == i.product.delivery_price                   render :action => "cart"                 end               end           else               @line_items.each |i|                 if i.price == i.product.foodio_price                   render :action => "cart"                 end               end           end       end 

it gives error of many render or redirect calls

the clue's in error message -- can render or redirect once per action.

try adding return straight after each call render.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -