Skip to content

Commit

Permalink
Don't delegate preview methods to controller.
Browse files Browse the repository at this point in the history
The controller will try to load the Election from the params but when
rendering an election that's the single one in a voting there are no
params. Instead, it's better to use the model in the cell.
  • Loading branch information
oriolgual committed Mar 26, 2022
1 parent 401a2fb commit 0253923
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ module Elections
# This cell renders the results
# for a given instance of an Election
class ElectionVoteCtaCell < Decidim::ViewModel
include Decidim::Elections::HasVoteFlow

delegate :current_user,
:current_participatory_space,
:preview_mode?,
:can_preview?,
:vote_flow,
to: :controller

private

# This is needed by HasVoteFlow
def election
model
end

def last_vote
@last_vote ||= Decidim::Elections::Votes::LastVoteForVoter.for(model, vote_flow.voter_id) if vote_flow.has_voter?
end
Expand Down

0 comments on commit 0253923

Please sign in to comment.