Reputation: 250
I have Event Calendar. I have standart link to create new event (it was created in views by scaffolding):
<%= link_to 'New Event', new_event_path %>
Now I need put same link to each day of calendar table and pass the date as parameter to controller
I do:
<%= link_to '+', new_event_path(date) %>
And I would like to have it in controller and do something like that
def new
@event = Event.new
if params[:date]
@event.date = params[:date]
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @event }
end
end
But it doesn't work. If I click to my new link I get the URL like http://localhost:3000/events/new.2013-04-02
and a blank page.
How it should be realized correctly?
Upvotes: 0
Views: 1293
Reputation: 115541
You can pass additional like this:
<%= link_to '+', new_event_path(date: date) %>
Upvotes: 1