mondayguy
mondayguy

Reputation: 991

ruby on rails form_tag with ajax

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?

Upvotes: 2

Views: 367

Answers (1)

Adnan Devops
Adnan Devops

Reputation: 503

Add the following to your routes:

post 'filter' => 'controller_name#filter'

Upvotes: 1

Related Questions