feat(campaign_gift_option): add strong params

This commit is contained in:
Luis Castro 2019-08-06 14:36:31 +02:00 committed by Eric Schultz
parent 399c421f38
commit 51a4902991
2 changed files with 18 additions and 14 deletions

View file

@ -17,14 +17,14 @@ class CampaignGiftOptionsController < ApplicationController
def create def create
campaign = current_campaign campaign = current_campaign
json_saved CreateCampaignGiftOption.create(campaign, params[:campaign_gift_option]), json_saved CreateCampaignGiftOption.create(campaign, campaign_gift_option_params),
'Gift option successfully created!' 'Gift option successfully created!'
end end
def update def update
@campaign = current_campaign @campaign = current_campaign
gift_option = @campaign.campaign_gift_options.find params[:id] gift_option = @campaign.campaign_gift_options.find params[:id]
json_saved UpdateCampaignGiftOption.update(gift_option, params[:campaign_gift_option]), 'Successfully updated' json_saved UpdateCampaignGiftOption.update(gift_option, campaign_gift_option_params), 'Successfully updated'
end end
# put /nonprofits/:nonprofit_id/campaigns/:campaign_id/campaign_gift_options/update_order # put /nonprofits/:nonprofit_id/campaigns/:campaign_id/campaign_gift_options/update_order
@ -39,4 +39,10 @@ class CampaignGiftOptionsController < ApplicationController
render_json { DeleteCampaignGiftOption.delete(@campaign, params[:id]) } render_json { DeleteCampaignGiftOption.delete(@campaign, params[:id]) }
end end
private
def campaign_gift_option_params
params.require(:campaign_gift_option).permit(:amount_one_time, :amount_recurring, :amount_dollars, :description, :name, :campaign, :quantity, :to_ship, :order, :hide_contributions)
end
end end

View file

@ -2,8 +2,6 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
class CampaignGiftOption < ApplicationRecord class CampaignGiftOption < ApplicationRecord
# TODO
# attr_accessible \
# :amount_one_time, #int (cents) # :amount_one_time, #int (cents)
# :amount_recurring, #int (cents) # :amount_recurring, #int (cents)
# :amount_dollars, #str, gets converted to amount # :amount_dollars, #str, gets converted to amount