class SpacesController < ApplicationController
  def index
    @dojo_count        = Dojo.count
    @regions_and_dojos = Dojo.eager_load(:prefecture).default_order.group_by { |dojo| dojo.prefecture.region }
  end
end

class SpacesController < ApplicationController
  def index
    @dojo_count        = Dojo.count
    @regions_and_dojos = Dojo.group_by_region
  end
end

Use a class method instead
Use a class method instead
