From e1287683f598d2c0c12f1e0211da77da3160b5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasia=20Jarmo=C5=82kowicz?= Date: Wed, 30 May 2018 17:00:06 +0200 Subject: [PATCH] Better slugs for campaigns --- app/controllers/campaigns_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index 00fa75c3..815959a1 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -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)