views:

61

answers:

1

Hello fellas, My logic tests an inventory supply; and the < operator functions fine. How do I assign boolean values to "instock"? (using POST) In this test, under both conditions the value remains unchanged and this sample code does not work.

Also this code is placed in an html.erb file, is there a better place for this code?

 <% if @inventory.needed < @inventory.amount then %>
         <%  @inventory.instock = 'true' %>
        <% else %>
           <% @inventory.instock = 'false' %>
        <% end %>

Thank you in advance for your suggestions!

+1  A: 

You are setting instock equal to the string value of "true".

@inventory.instock = true

Is what you want...

bensie
Also, that code belongs in your controller since you're not displaying anything that depends on those values.
bensie