Better slugs for campaigns

This commit is contained in:
Kasia Jarmołkowicz 2018-05-30 17:00:06 +02:00 committed by Eric Schultz
parent 79427774e5
commit e1287683f5

View file

@ -160,7 +160,10 @@ class CampaignsController < ApplicationController
p2p_params = params.except(:nonprofit_id, :summary,:goal_amount)
p2p_params.merge!(parent_campaign.child_params)
p2p_params[:slug] = Format::Url.convert_to_slug "#{p2p_params[:name]}-#{profile.name}"
base_slug = Format::Url.convert_to_slug "#{p2p_params[:name]}-#{profile.name}"
algo = SlugP2pCampaignNamingAlgorithm.new(p2p_params[:nonprofit_id])
p2p_params[:slug] = algo.create_copy_name(base_slug)
campaign = Campaign.create(p2p_params)