Skip to content

Commit 3c3bae4

Browse files
committed
スマートフォン版のDojo表示を地方ごとから都道府県ごとに変更
1 parent 92fbd66 commit 3c3bae4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/controllers/home_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ class HomeController < ApplicationController
22
def show
33
@dojo_count = Dojo.active_dojos_count
44
@regions_and_dojos = Dojo.group_by_region_on_active
5+
@prefectures_and_dojos = Dojo.group_by_prefecture_on_active
56
end
67
end

app/models/dojo.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ def group_by_region_on_active
4747
active.group_by_region
4848
end
4949

50+
def group_by_prefecture
51+
eager_load(:prefecture).default_order.group_by { |dojo| dojo.prefecture.name }
52+
end
53+
54+
def group_by_prefecture_on_active
55+
active.group_by_prefecture
56+
end
57+
5058
def aggregatable_annual_count(period)
5159
Hash[
5260
joins(:dojo_event_services)

app/views/shared/_dojos.html+smartphone.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<div id="accordion" class="panel-group" aria-multiselectable="true" role="tablist">
2-
<% regions_and_dojos.each_with_index do |(region, dojos), index| %>
2+
3+
<% @prefectures_and_dojos.each_with_index do |(prefecture, dojos), index| %>
34
<div class="panel panel-default">
45
<div class="panel-heading" id="heading<%= index %>" role="tab">
56
<h4 class="panel-title">
67
<a data-toggle="collapse"
78
href="#collapse<%= index %>" role="button">
89
<i class="fa fa-chevron-right" aria-hidden="true"></i>
9-
<%= region %>
10+
<%= prefecture %>
1011
- <%= dojos.pluck(:counter).sum %> Dojos
1112
</a>
1213
</h4>

0 commit comments

Comments
 (0)