I made a before_filter in some of my controller to redirect keyword searches to the parent controller
It\'s very simple:
before_filter :redirect_se
I think the problem is in the view which is doing the request
you are sending a JS request (ajax), so you should return a js.erb file and render new HTML using js
Try with
def redirect_search
respond_to do |format|
format.html {redirect_to buildings_path} if params[:q].present?
format.js {render :js => "window.location.href='"+buildings_path+"'"} if params[:q].present?
end
end
Thanks to Bachan's answer, I could solve my issue this way:
def redirect_search
render :js => "window.location.href='"+buildings_path+"'" if params[:q].present?
end
Thanks!