diff --git a/app/controllers/federal_subjects_controller.rb b/app/controllers/federal_subjects_controller.rb index 53166c1..792b9ad 100644 --- a/app/controllers/federal_subjects_controller.rb +++ b/app/controllers/federal_subjects_controller.rb @@ -9,7 +9,7 @@ class FederalSubjectsController < ApplicationController @federal_subjects = policy_scope(FederalSubject).order_by_display_name end - # GET /federal_subjects/:id + # GET /federal_subjects/:number def show authorize @federal_subject end @@ -17,6 +17,6 @@ class FederalSubjectsController < ApplicationController private def set_federal_subject - @federal_subject = FederalSubject.find params[:id] + @federal_subject = FederalSubject.find_by! number: params[:number] end end diff --git a/app/models/federal_subject.rb b/app/models/federal_subject.rb index be6019e..799bdd4 100644 --- a/app/models/federal_subject.rb +++ b/app/models/federal_subject.rb @@ -54,6 +54,10 @@ class FederalSubject < ApplicationRecord # Methods # ########### + def to_param + number&.to_s + end + def display_name if I18n.locale == :ru native_name diff --git a/app/views/federal_subjects/index.html.erb b/app/views/federal_subjects/index.html.erb index 33b392c..ddfd970 100644 --- a/app/views/federal_subjects/index.html.erb +++ b/app/views/federal_subjects/index.html.erb @@ -2,9 +2,6 @@
- <%= FederalSubject.human_attribute_name :id %> - | <%= FederalSubject.human_attribute_name :number %> | @@ -24,7 +21,6 @@||
---|---|---|---|
<%= federal_subject.id %> | <%= federal_subject.number %> | <%= federal_subject.display_name %> | <%= federal_subject.centre %> | diff --git a/app/views/federal_subjects/show.html.erb b/app/views/federal_subjects/show.html.erb index c1abcd6..d43e9ce 100644 --- a/app/views/federal_subjects/show.html.erb +++ b/app/views/federal_subjects/show.html.erb @@ -8,9 +8,6 @@