Reputation: 481
parameter
"day" => "2013-11-21"
controller
date = params[:day] # gives me a nil value back
@event = Event.new(date: date, id: date.id)
view
...
<% f.hidden_field :id, :value => :day %>
...
Here are the parameters:
{"utf8"=>"✓",
"authenticity_token"=>"lxKzvpGx8nmutI8X8sdZGNaKZ8w1kJEdF/B8ixtqpqA=",
"event"=>{"title"=>"",
"description"=>"",
"day"=>"2013-11-21",
"start(1i)"=>"2013",
"start(2i)"=>"11",
"start(3i)"=>"22",
"start(4i)"=>"08",
"start(5i)"=>"00",
"end(1i)"=>"2013",
"end(2i)"=>"11",
"end(3i)"=>"22",
"end(4i)"=>"08",
"end(5i)"=>"00"},
"commit"=>"Create Event"}
why gives it to me a nil value back?
let me know if you need something more
Upvotes: 0
Views: 67
Reputation: 51151
I see at least three problems.
params[:event][:day]
, as you should see in the parameters list you posted.params[:event][:day]
parameter. Actually, it does nothing as it isn't even being rendered (because of <%
usage, instead of <%=
.id
on it (in @event = Event.new(date: date, id: date.id)
line). Even if you refer to that parameter properly, it will raise an error. Upvotes: 1