Commit a389dc8
Changed files (4)
app
config
locales
app/controllers/gyms_controller.rb
@@ -1,5 +1,5 @@
class GymsController < ApplicationController
- before_action :provide_search_path
+ before_action { @search_path = gyms_path }
def index
@gyms = Gym.search_with(params).closest_to(current_session.location).includes(:location)
@@ -29,8 +29,4 @@ class GymsController < ApplicationController
location_attributes: [:address, :city, :region, :country, :postal_code]
)
end
-
- def provide_search_path
- @search_path = gyms_path
- end
end
app/helpers/application_helper.rb
@@ -7,7 +7,9 @@ module ApplicationHelper
class: "gravatar"
end
- def search_path
- @search_path || dashboard_path
+ def search_form(search_path: @search_path || dashboard_path, remote: false)
+ form_tag search_path, id: "search-form", method: :get, remote: remote do
+ search_field_tag :q, params[:q], placeholder: t(:search)
+ end
end
end
app/views/layouts/application.html.erb
@@ -32,11 +32,7 @@
<!-- Right Nav Section -->
<ul class="right">
<% if feature_available?(:gym) %>
- <li>
- <%= form_tag search_path, id: "search-form", method: :get, remote: true do %>
- <%= search_field_tag :q, params[:q], placeholder: t('.search') %>
- <% end %>
- </li>
+ <li> <%= search_form %> </li>
<li class="divider"></li>
<li><%= link_to t(".gyms"), gyms_path %></li>
<% end %>
config/locales/en.yml
@@ -20,6 +20,7 @@
# available at http://guides.rubyonrails.org/i18n.html.
en:
+ search: Search
layouts:
application:
gyms: Gyms
@@ -30,7 +31,6 @@ en:
log_out: "Log out"
profile_edit: "Edit profile"
profile_view: "View profile"
- search: Search
title: Stronglifters
gyms:
index: