```ruby
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
```

Use a class method instead
user
```ruby
class SpacesController < ApplicationController
  def index
    @dojo_count        = Dojo.count
    @regions_and_dojos = Dojo.group_by_region
  end
end
```
assistant