Ok so i have a form
<form action="/search" method="post">
<input type="hidden" name="location_id" value="1" /><br />
<input class='small' data-datepicker='datepicker' name='start_date' type='text' value='03-09-2012'>
<input class='small' data-datepicker='datepicker' name='end_date' type='text' value='03-09-2012'>
</form>
and i have the route
match "/search", :to => "locations#search"
and in my controller
def search
@location = Location.find(params[:location_id])
start_date = DateTime.strptime(params[:start_date], "%m-%d-%Y")
end_date = DateTime.strptime(params[:end_date], "%m-%d-%Y")
@songs = @location.songs.paginate(:page => params[:page], :per_page => 30, :conditions => {:play_date => start_date..end_date})
render 'show'
end
All works perfect other then when i click on page 2 or next the page errors because i dont have the location_id or the dates in the params….any idea on how to fix this…i am using the will_paginate gem
Error
Couldn't find Location without an ID
Parameters:
{"page"=>"2"}
You need to add location_id params to your will_paginate view helper like this:
Hope it helps.