fixes conflicts with budgets

This commit is contained in:
rgarcia
2017-01-09 13:33:01 +01:00
36 changed files with 248 additions and 255 deletions

View File

@@ -5,14 +5,16 @@ module Budgets
before_action :load_ballot
def show
authorize! :show, @ballot
render template: "budgets/ballot/show"
end
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

View File

@@ -18,7 +18,7 @@ module Budgets
feature_flag :budgets
has_orders %w{most_voted newest oldest}, only: :show
has_orders ->(c){ c.instance_variable_get(:@budget).balloting? ? %w{random price} : %w{random confidence_score} }, only: :index
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
@@ -83,7 +83,7 @@ module Budgets
end
def investment_params
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :terms_of_service, :location, :tag_list)
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, :organization_name, :location, :terms_of_service)
end
def load_ballot