Routes question rails 3.0 vs. rails 2.0

I have been trying to get Solr up and running and have an app mostly
working but simple routes stuff is tripping me up. This is a Rails 3.0
route.

PlayingWithSunspot::Application.routes.draw do
resources :jobs do
collection do
get :search
end
end

So, what would the Rails 2.3.11 equivalent be for this route? I can’t
seem to get the right syntax though I thought this was an example of a
resource route with a complex sub-resource.

Phil

On Sat, Apr 16, 2011 at 9:29 PM, sol.manager [email protected]
wrote:

So, what would the Rails 2.3.11 equivalent be for this route? I can’t
seem to get the right syntax though I thought this was an example of a
resource route with a complex sub-resource.

Rails used to do this like:

map.resources :jobs, :collection => {:search => :get}

You can also still find the rails 2.3.x rails guides, which includes the
routing guide, from the index page of http://guides.rubyonrails.org/

On Apr 16, 11:58pm, Phil C. [email protected] wrote:

Phil

I tried this and it isn’t working out.
I have a job model. In the views/jobs/index.html.erb file I have the
following at the top.

Listing jobs

<%= form_tag search_jobs_path, :method => :get do %>

<%= text_field_tag :query, params[:query] %> <%= submit_tag "Search!" %>

<% end %>

When i put in the route as below and try to pull up the jobs index, I
now get a compile error. It does not like this line:
<%= form_tag search_jobs_path, :method => :get do %>

So what am I missing here?

On Sun, Apr 17, 2011 at 12:59 PM, sol.manager [email protected]
wrote:

What is the error?

The full error message goes something like this:

showing app/views/jobs/_search_form.html.erb where line #1 raised:

compile error
/Users/aesthetica/Apps/blank-r2311/app/views/jobs/
_search_form.html.erb:1: syntax error, unexpected ‘)’
…obs_path, :method => :get do ).to_s); @output_buffer.concat
^
/Users/aesthetica/Apps/blank-r2311/app/views/jobs/
_search_form.html.erb:6: syntax error, unexpected kENSURE, expecting
‘)’
/Users/aesthetica/Apps/blank-r2311/app/views/jobs/
_search_form.html.erb:8: syntax error, unexpected kEND, expecting ‘)’
Extracted source (around line #1):

1: <%= form_tag search_jobs_path, :method => :get do %>
2:


3: <%= text_field_tag :query, params[:query] %> <%= submit_tag
“Search!” %>
4:


Trace of template inclusion: app/views/jobs/_search_form.html.erb, app/
views/jobs/index.html.erb

This totally fixed the problem and my app is now properly doing Solr
full text searches of my jobs model. Thank you for the assistance.

On Sun, Apr 17, 2011 at 4:17 PM, sol.manager [email protected]
wrote:

_search_form.html.erb:6: syntax error, unexpected kENSURE, expecting
‘)’
/Users/aesthetica/Apps/blank-r2311/app/views/jobs/
_search_form.html.erb:8: syntax error, unexpected kEND, expecting ‘)’
Extracted source (around line #1):

1: <%= form_tag search_jobs_path, :method => :get do %>

Problem is not the route, then. This line (above) should not have an ‘=’
sign at the beginning. Try

<% form_tag search_jobs_path, :method => :get do %>

Google doesn’t seem to want to post my reply properly. I wanted to say
thank you as your last suggestion worked. I removed the offending =
and my site is working with Solr properly now. Thank you.