2

My view:

 <%= form_tag('filter', remote: true) do %>
      <%= label_tag(:q, "от:") %>
      <%= text_field_tag(:q, "", class: 'input.in') %>
      <%= submit_tag("Search") %>
 <% end %>

My controller:

def filter
    respond_to do |format|
       format.js
    end 
end
filter.js.erb:
alert(1);

I'm getting error in console POST http://localhost:3000/filter 404 (Not Found) jquery.js?body=1:8707 What am I doing wrong?

4
  • what you have written in routes.rb? Commented May 30, 2015 at 9:14
  • @user123, I have to? I didn't write anything, in tutorial there is nothing about routes, I thought that no need in ajax request for it. Correct me plz, if I'm not right Commented May 30, 2015 at 9:18
  • Your routes will be as: post 'filter' => 'controller_name#filter' Commented May 30, 2015 at 9:19
  • @AdnanDevops, Thank you. It works now, can you add it to andwers? Commented May 30, 2015 at 9:28

1 Answer 1

1

Add the following to your routes:

post 'filter' => 'controller_name#filter'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.