diff --git a/app/controllers/budgets/executions_controller.rb b/app/controllers/budgets/executions_controller.rb index d4b9cd740..54decebee 100644 --- a/app/controllers/budgets/executions_controller.rb +++ b/app/controllers/budgets/executions_controller.rb @@ -25,7 +25,7 @@ module Budgets end def load_budget - @budget = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budgetid]) + @budget = Budget.find_by_slug_or_id params[:budget_id] end def investments_by_heading_ordered_alphabetically diff --git a/app/models/concerns/sluggable.rb b/app/models/concerns/sluggable.rb index 495ffaf77..8fb308d22 100644 --- a/app/models/concerns/sluggable.rb +++ b/app/models/concerns/sluggable.rb @@ -3,6 +3,10 @@ module Sluggable included do before_validation :generate_slug, if: :generate_slug? + + def self.find_by_slug_or_id(slug_or_id) + find_by_slug(slug_or_id) || find_by_id(slug_or_id) + end end def generate_slug