GavinBelson
GavinBelson

Reputation: 2784

Reading in rails parameters to controller

I have the parameters below being sent from a <%= form_for(bid) do |f| %> in a form to create a new bid.

{
  "utf8"=>"✓",
  "authenticity_token"=>"kb1enToURu/KEIw4DbBKnuLScDjhkli1cwA==",
  "bid"=>{"amount"=>"34", "item_id"=>"5877e25a31d77f202480a5a9", "person_id"=>"58718f3431d77f288b9be837"},
  "commit"=>"Create Bid"
}

The create controller receives the request:

def create
  @bid = Bid.new(params[bid]) #need help here to create new bid
  render :index
end

The current create method gives me an "undefined local variable or method `bid' for #BidsController..."

How do I change the create method in the controller to read in the parameters and save the bid?

Upvotes: 0

Views: 910

Answers (1)

Zzz
Zzz

Reputation: 1703

change params[bid] to params[:bid]

Upvotes: 2

Related Questions