diff --git a/app/controllers/districts_controller.rb b/app/controllers/districts_controller.rb index ff772074..aacc239a 100644 --- a/app/controllers/districts_controller.rb +++ b/app/controllers/districts_controller.rb @@ -66,7 +66,7 @@ class DistrictsController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_district - @district = District.find(params[:id]) + @district = District.find_by_slug(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/models/district.rb b/app/models/district.rb index bf80d381..9f5b063d 100644 --- a/app/models/district.rb +++ b/app/models/district.rb @@ -5,4 +5,12 @@ class District < ApplicationRecord scope :alphabetic, -> { order(name: :asc) } + include FriendlyId + + friendly_id :name, use: [:slugged] + + before_save do + self.slug ||= name.parameterize + end + end diff --git a/app/presenters/construct_graph_row_presenter.rb b/app/presenters/construct_graph_row_presenter.rb index c463617d..187acb6c 100644 --- a/app/presenters/construct_graph_row_presenter.rb +++ b/app/presenters/construct_graph_row_presenter.rb @@ -1,5 +1,4 @@ class ConstructGraphRowPresenter - def initialize(construct:, score:) @construct = construct @score = score diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index ecb8c708..e59ba1ab 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -8,7 +8,7 @@