I can use the search bar in every pages but I can not use autocomplete until refresh the page.
You can find "layouts/header.html.erb" , "User model" , "users_controller" , "routes.rb" in this link Autocompleted search form is not working in all pages
Gemfile
gem 'rails', '4.2.4'
gem 'bcrypt', '~> 3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.36.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem "searchkick"
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
gem 'make_flaggable', :git => 'git://github.com/medihack/make_flaggable'
application.html.erb
<head>
<title><%= yield(:title) %> | Blogger </title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<!-- Using it for autocomplete -->
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js" %>
<!-- -->
< %= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
layouts/shim
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js">
</script>
<![endif]-->
user.js.coffee
$ ->
$('#user_search').typeahead
name: "user"
remote: "/users/autocomplete?query=%QUERY"