feat(campaign_gift_option): add strong params
This commit is contained in:
parent
399c421f38
commit
51a4902991
2 changed files with 18 additions and 14 deletions
|
@ -17,14 +17,14 @@ class CampaignGiftOptionsController < ApplicationController
|
|||
|
||||
def create
|
||||
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!'
|
||||
end
|
||||
|
||||
def update
|
||||
@campaign = current_campaign
|
||||
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
|
||||
|
||||
# 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]) }
|
||||
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
|
||||
|
|
|
@ -2,18 +2,16 @@
|
|||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class CampaignGiftOption < ApplicationRecord
|
||||
# TODO
|
||||
# attr_accessible \
|
||||
# :amount_one_time, #int (cents)
|
||||
# :amount_recurring, #int (cents)
|
||||
# :amount_dollars, #str, gets converted to amount
|
||||
# :description, # text
|
||||
# :name, # str
|
||||
# :campaign, #assocation
|
||||
# :quantity, #int (optional)
|
||||
# :to_ship, #boolean
|
||||
# :order, #int (optional)
|
||||
# :hide_contributions #boolean (optional)
|
||||
# :amount_one_time, #int (cents)
|
||||
# :amount_recurring, #int (cents)
|
||||
# :amount_dollars, #str, gets converted to amount
|
||||
# :description, # text
|
||||
# :name, # str
|
||||
# :campaign, #assocation
|
||||
# :quantity, #int (optional)
|
||||
# :to_ship, #boolean
|
||||
# :order, #int (optional)
|
||||
# :hide_contributions #boolean (optional)
|
||||
|
||||
belongs_to :campaign
|
||||
has_many :campaign_gifts
|
||||
|
|
Loading…
Reference in a new issue