I want a form on my home page to be handled by a different controller
(buy_controller) but I''m having issues. The code works fine when I
have the form under the "buy" views
I''m pretty new to Rails. I''ve tried different ways of doing
this but
I can''t seem to figure it out. The latest error is doesn''t
let me
load the home page.
Error
*************************************
ActionController::RoutingError in Home#index
Showing home/index.rhtml where line #42 raised:
buy_url failed to generate from
{:controller=>"buy", :action=>"search_for_product"},
expected:
{:controller=>"buy", :action=>"show"}, diff:
{:action=>"show"}
Extracted source (around line #42):
39: <div id="search">
40: <h1 class="mh"><%= "Product Search".t
%></h1>
41: <div id="search_field">
42: <% form_for :buy, :url => buy_path(:action =>
''search_for_product''), :html => { :id =>
''search_form'' } do |form| %>
43: <%= form.text_field :query, :size => 70 -%>
44: <%= submit_tag "Search".t %>
45: <img id=''query_indicator''
src=''/images/
live_tree_loading_spinner.gif'' style=''display:none;''
alt="loading" />
Here is my code:
routes.rb
*************************************
map.resources :buy
/home/index.rhtml
*************************************
<% form_for :buy, :url => buy_path(:action =>
''search_for_product''), :html => { :id =>
''search_form'' } do |form| %>
<%= form.text_field :query, :size => 70 -%>
<%= submit_tag "Search" %>
<% end %>
buy_controller
*************************************
def search_for_product
if params[:buy][:query].blank?
...
end
if @fail
flash[:error] = @err_msg
redirect_to :back
else
respond_to do |format|
format.html { render :template => ''buy/search'',
:layout => ''buy'' } # search.rhtm
end
end
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---