Skip to content

Dojo order #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/plain_page_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class PlainPageController < CmsController
#skip_before_action :verify_authenticity_token, only: [:index]

def index
@dojos = Dojo.all
@dojos = Dojo.default_order.all
end
end
2 changes: 1 addition & 1 deletion app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class StaticPagesController < ApplicationController
def home
@dojo_count = Dojo.count
@regions_and_dojos = Dojo.includes(:prefecture).group_by { |dojo| dojo.prefecture.region }
@regions_and_dojos = Dojo.includes(:prefecture).default_order.group_by { |dojo| dojo.prefecture.region }
end

def letsencrypt
Expand Down
3 changes: 2 additions & 1 deletion app/models/dojo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class Dojo < ApplicationRecord
has_many :event_histories, dependent: :destroy

serialize :tags
default_scope -> { order(order: :asc) }
before_save { self.email = self.email.downcase }

scope :default_order, -> { order(prefecture_id: :asc) }

validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: false
validates :order, presence: false
Expand Down