Reputation: 43
I am having some trouble getting my controller to read the value in my taxable param. I think it may be this if params[:taxable] == "0"
, but I have tried a ton of different combinations with no luck.
order form
<%= f.input :taxable, :as => :boolean %>
order controller
def create
@order = Order.new(
:taxable => params[:order][:taxable],
)
if params[:taxable] == "0"
@order.tax = 0
else
@order.tax = (get_tax_for_order(@order))
end
end
order model
class Order < ActiveRecord::Base
attr_accessor :taxable
def order_params
params.require(:order).permit(:taxable)
end
Upvotes: 0
Views: 35
Reputation: 33552
As i said,this line
if params[:taxable] == "0"
should be
if params[:order][:taxable] == "0"
As the taxable
is within the order
hash.
Upvotes: 1