I have a controller which respond_to format.js, however, most request assume the old format.html still exists and throws a 404 exception. How do I capture all MIME request on the controller and redirect them only to format.js?
Here's the current controller action
def search
respond_to do |format|
unless @search.nil?
format.js { render :partial => '/search/search_form', :status => 200 }
else
format.js { render :partial => '/search/not_exist', :status => 500 }
end
end
end
I'm trying to do something like this, (I know this is invalid, just for demonstration).
def search
respond_to(:html) do |format|
unless @search.nil?
format.js { render :partial => '/search/search_form', :status => 200 }
else
format.js { render :partial => '/search/not_exist', :status => 500 }
end
end
end