M
M
Max2015-12-08 17:49:37
Ruby on Rails
Max, 2015-12-08 17:49:37

Why doesn't the button always work in Rails?

Hello, I did a basic search, but I can't figure out why the search button doesn't always work.

<%= form_tag users_path, :method => 'get' do %>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "Search" %>
<% end %>

def index
    @users = User.where(["name LIKE ?","%#{params[:search]}%"]) 
  end

When I open a page with a search field for the first time, the button works. But if you try to search again, it will not work., when you click, nothing happens. It feels like the form only works after you go to it from another page. Hard to explain to be honest

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Burmakin, 2015-12-08
@Freika

Read up on what Turbolinks are, turn them off, or use the jquery-turbolinks gem (but better off).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question