Deactivates /ballot view when not in the balloting phase
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user