I'm almost there, just need a small push

I’m using the restful2 application from the Agile Web D. with
Rails
and have added a search to the articles_controller.rb and added the
route to the routes.rb as: map.resources :articles, :collection =>
{:search => :get }

I need some help on how to call the function. I get the error:
“no route found to match “/search” with {:method=>:get}”
when using this code on the index.rhtml form:

But this works in the address bar:
http://localhost:3000/articles;search?Ndc=First

How can I get the code in the index.rhtml to call correctly or what is
the correct syntax for the form action?

David Allen wrote:

I’m using the restful2 application from the Agile Web D. with
Rails
and have added a search to the articles_controller.rb and added the
route to the routes.rb as: map.resources :articles, :collection =>
{:search => :get }

I need some help on how to call the function. I get the error:
“no route found to match “/search” with {:method=>:get}”
when using this code on the index.rhtml form:

But this works in the address bar:
http://localhost:3000/articles;search?Ndc=First

How can I get the code in the index.rhtml to call correctly or what is
the correct syntax for the form action?

Hey, this works:

Does anyone know a better way?

On Aug 21, 2007, at 10:10 AM, David Allen wrote:

Hey, this works:

Use the helpers?

<% form_tag(search_articles_path) do %>
<%= text_field_tag “Ndc” %>
<%= submit_tag “Search” %>
<% end %>

(It may be articles_search_path instead of search_articles_path, I
never can remember.)

David Allen wrote:

wont work because you dont have a route defined for it. In your routes.rb file you've told rails that the search action is a collection related to articles, so your URL would be:

/articles;search

If you want it to be /search then you’d need to add:

map.search ‘/search’, :controller => ‘articles’, :action => ‘search’

but then you’ll probably need to change your controller around. Might
not work right off the bat.

Read the peepcode rest cheat sheet.