![]() | Recipe 2 Search Issues |
|
26 Jun 2010, 05:14
Tony Spore (4 posts) |
I am trying to get the search to show results however after looking and looking I don’t see why I get this error: In the Controller it looks like this – def search @events = Event.search(params[:q]) respond_to do |format| format.html @search.html.erb format.xml { render :xml => @events } end end my Routes look like this – map.resources :events, :collection => { :search => :get }, :member => { :copy => :post } What am I doing wrong? |
|
26 Jun 2010, 05:19
Tony Spore (4 posts) |
Here is my log info: Processing EventsController#show (for 127.0.0.1 at 2010-06-25 22:12:27) [GET] Parameters: {“commit”=>”Search Events”, “id”=>”search”, “q”=>”shortest”} Event Load (0.1ms) SELECT * FROM “events” WHERE (“events”.”id” = 0) ActiveRecord::RecordNotFound (Couldn’t find Event with ID=search): app/controllers/events_controller.rb:18:in `show’ Rendered rescues/_trace (30.4ms) |
|
26 Jun 2010, 10:51
Seth Arnold (22 posts) |
First, I think the I believe you need to restart your application before routing changes are integrated into the application. If you haven’t restarted since adding the new search route… http://localhost:3000/events/search?q=blah sure looks like a request to load the event with the ID ‘search’. Hope this helps. :) |
|
26 Jun 2010, 16:07
Tony Spore (4 posts) |
Maybe its a bug in my active record- I just wish I understood ruby a bit more. Hence the book. So this is a good exercise for me to learn I guess. Processing EventsController#show (for 127.0.0.1 at 2010-06-26 09:01:03) [GET]
Parameters: {"commit"=>"Search Events", "id"=>"search", "q"=>"fish"}
Event Load (0.1ms) SELECT * FROM "events" WHERE ("events"."id" = 0)
ActiveRecord::RecordNotFound (Couldn't find Event with ID=search):
app/controllers/events_controller.rb:18:in `show' |
|
27 Jun 2010, 01:34
Seth Arnold (22 posts) |
Because there is a Is the view for the form using form_for? If so, it should probably just be using “form_tag” or something similar. Is the submit action of the form hard-coded to the show action? If those aren’t it, then I suggest pasting the entire view, action, and model code for this, along with the routing, and hope someone with keener eyes can spot the trouble. :) Good luck |
| You must be logged in to comment |

