From 51ab4a430e1a62dc854aaff82fe6eca19e8d7cba Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 30 Jun 2017 21:41:47 +0200 Subject: [PATCH] Load budget in stats controller --- app/controllers/budgets/stats_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/budgets/stats_controller.rb b/app/controllers/budgets/stats_controller.rb index 48a93c5e7..558a00865 100644 --- a/app/controllers/budgets/stats_controller.rb +++ b/app/controllers/budgets/stats_controller.rb @@ -1,6 +1,7 @@ module Budgets class StatsController < ApplicationController + before_action :load_budget load_and_authorize_resource :budget def show @@ -14,5 +15,9 @@ module Budgets Budget::Stats.new(@budget).generate end + def load_budget + @budget = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budget_id]) + end + end end