I have a coupon system, and I'm trying to get the coupon
object with the method find_by
:
Coupon.find_by_coupon(params[:coupon])
I'm getting this error:
ArgumentError Exception: Unknown key: coupon
I'm sure params[:coupon]
is right:
(rdb:1) eval params[:coupon]
{"coupon"=>"100"}
I have the following model:
# Table name: coupons
#
# id :integer not null, primary key
# coupon :string(255)
# user_id :integer
UPDATE:
It's working if I put Coupon.find_by_coupon(params[:coupon][:coupon])
instead of Coupon.find_by_coupon(params[:coupon])
.
Here the code with the form in my view:
<%= semantic_form_for Coupon.new, url: payment_summary_table_offers_path(@booking_request) do |f| %>
<%= f.input :coupon, :as => :string, :label => false, no_wrapper: true %>
<%= f.action :submit, :as => :button, :label => t(:button_use_coupon), no_wrapper: true,
button_html: { value: :reply, :disable_with => t(:text_please_wait) } %>
<% end %>