views:

346

answers:

3

I'm using form_remote_tag(:url => {:controller => "home", :action => "search"}, :update => "mydiv"). When I click submit on the form "mydiv" is populated with the error "Template is missing. Missing template home/search.erb in view path app/views". I've tried multiple render options in def search, but they all result in the same error.

It looks like the search method is trying to use it's default render even though I'm specifying what I want.

I've tried:
render 'index'
render :text => 'Return this from my method!'

Is my url incorrect? Is it not submitting back to my home controller's search method?

A: 

Try

render :action => 'index'

this will use "index.rhtml" or "index.html.erb".

Alex Kaushovik
I believe his use of `render 'index'` is the same as `render :action => 'index'`... I think...
Joseph Silvashy
Add this in my search method? Unfortunately, it doesn't look like the submit is hitting the search method at all.
Donald Hughes
A: 

The form_remote_tag needs prototype to function. Make sure you are including the :defaults for your javascript libraries namely prototype.

<%= javascript_include_tag :defaults %>
Joseph Silvashy
it's included in my default layout file, which I've set `render :layout => false` in the search method. If I leave the layout then "mydiv" is populated with the whole page.
Donald Hughes
If this were the solution he would not be getting missing template errors
EmFi
A: 

I will try to explain why it said search.erb is not found, lets take create action for a some model, if there is some error in my create action they it will throw missing template create.html.erb file, since you have some error in your create action rails will try to render the create.html.erb in the page. Hope I explained it clearly.

In an ajax action you can't use redirect_to or render options directly. try using this in your search action

render :update do |page|
  page.replace_html "ur_div_id","partial"
end
Vamsi