Deactivates /ballot view when not in the balloting phase

This commit is contained in:
kikito
2017-01-05 15:18:16 +01:00
parent 28e6a10382
commit 7eba0fee50

View File

@@ -3,6 +3,7 @@ module Budgets
before_action :authenticate_user!
load_and_authorize_resource :budget
before_action :load_ballot
authorize_resource :ballot, through: :budget
def show
render template: "budgets/ballot/show"
@@ -11,8 +12,9 @@ module Budgets
private
def load_ballot
@ballot = Budget::Ballot.where(user: current_user, budget: @budget).first_or_create
query = Budget::Ballot.where(user: current_user, budget: @budget)
@ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
end
end
end
end