Note we don't cast negative votes when users remove their support. That way we provide compatibility for institutions who have implemented real negative votes (in case there are / will be any), and we also keep the database meaningful: it's not that users downvoted something; they simply removed their upvote. Co-Authored-By: Javi Martín <javim@elretirao.net> Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
31 lines
841 B
Ruby
31 lines
841 B
Ruby
module Budgets
|
|
module Investments
|
|
class VotesController < ApplicationController
|
|
load_and_authorize_resource :budget
|
|
load_and_authorize_resource :investment, through: :budget, class: "Budget::Investment"
|
|
load_and_authorize_resource through: :investment, through_association: :votes_for, only: :destroy
|
|
|
|
def create
|
|
@investment.register_selection(current_user)
|
|
|
|
respond_to do |format|
|
|
format.html do
|
|
redirect_to budget_investments_path(heading_id: @investment.heading.id),
|
|
notice: t("flash.actions.create.support")
|
|
end
|
|
|
|
format.js { render :show }
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@investment.unliked_by(current_user)
|
|
|
|
respond_to do |format|
|
|
format.js { render :show }
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|