Use milestoneable instead of investment

This commit is contained in:
Javi Martín
2018-11-12 19:28:20 +01:00
parent 2c2831beb0
commit 2e778b4073

View File

@@ -1,7 +1,7 @@
class Admin::BudgetInvestmentMilestonesController < Admin::BaseController class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
include Translatable include Translatable
before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy] before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy]
before_action :load_milestone, only: [:edit, :update, :destroy] before_action :load_milestone, only: [:edit, :update, :destroy]
before_action :load_statuses, only: [:index, :new, :create, :edit, :update] before_action :load_statuses, only: [:index, :new, :create, :edit, :update]
helper_method :milestoneable_path helper_method :milestoneable_path
@@ -10,12 +10,12 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
end end
def new def new
@milestone = @investment.milestones.new @milestone = @milestoneable.milestones.new
end end
def create def create
@milestone = Milestone.new(milestone_params) @milestone = Milestone.new(milestone_params)
@milestone.milestoneable = @investment @milestone.milestoneable = @milestoneable
if @milestone.save if @milestone.save
redirect_to milestoneable_path, notice: t('admin.milestones.create.notice') redirect_to milestoneable_path, notice: t('admin.milestones.create.notice')
else else
@@ -51,8 +51,8 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
params.require(:milestone).permit(*attributes) params.require(:milestone).permit(*attributes)
end end
def load_budget_investment def load_milestoneable
@investment = Budget::Investment.find(params[:budget_investment_id]) @milestoneable = Budget::Investment.find(params[:budget_investment_id])
end end
def load_milestone def load_milestone