From aff213b0ef5f8725925a49572e7c6d9e662eaffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 12 Jul 2020 23:05:39 +0200 Subject: [PATCH] Remove redundant calls to load resources We already load the budget and the ballot in `before_action` calls, so we don't have to load them again. --- app/controllers/budgets/ballot/lines_controller.rb | 4 ++-- app/controllers/budgets/ballots_controller.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/budgets/ballot/lines_controller.rb b/app/controllers/budgets/ballot/lines_controller.rb index 124bfba83..e9df6ab2c 100644 --- a/app/controllers/budgets/ballot/lines_controller.rb +++ b/app/controllers/budgets/ballot/lines_controller.rb @@ -9,8 +9,8 @@ module Budgets before_action :load_investments before_action :load_ballot_referer - load_and_authorize_resource :budget - load_and_authorize_resource :ballot, class: "Budget::Ballot", through: :budget + authorize_resource :budget + authorize_resource :ballot load_and_authorize_resource :line, through: :ballot, find_by: :investment_id, class: "Budget::Ballot::Line" def create diff --git a/app/controllers/budgets/ballots_controller.rb b/app/controllers/budgets/ballots_controller.rb index 7015c8285..52b68c630 100644 --- a/app/controllers/budgets/ballots_controller.rb +++ b/app/controllers/budgets/ballots_controller.rb @@ -2,7 +2,7 @@ module Budgets class BallotsController < ApplicationController before_action :authenticate_user! before_action :load_budget - load_and_authorize_resource :budget + authorize_resource :budget before_action :load_ballot after_action :store_referer, only: [:show]