0

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 Answer 1

1

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

@inventory.instock = true

Is what you want...

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.