share links to debate

This commit is contained in:
palomahnhp
2016-02-07 22:20:59 +01:00
parent 885182aa93
commit 2ee90ac76e
19 changed files with 226 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ module CommentableActions
if @resource.save_with_captcha
track_event
redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id)
redirect_path = after_create_path
redirect_to redirect_path, notice: t("flash.actions.create.#{resource_name.underscore}")
else
load_categories
@@ -153,4 +153,8 @@ module CommentableActions
def index_customization
nil
end
def after_create_path
url_for(controller: controller_name, action: :show, id: @resource.id)
end
end

View File

@@ -0,0 +1,26 @@
class DebateLinksController < ApplicationController
include CommentableActions
load_and_authorize_resource class: "Debate"
respond_to :html, :js
private
def create_params
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key)
end
def debate_params
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key)
end
def after_create_path
debate_path(@resource)
end
def resource_model
Debate
end
end

View File

@@ -26,7 +26,7 @@ class DebatesController < ApplicationController
private
def debate_params
params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service, :captcha, :captcha_key)
params.require(:debate).permit(:title, :description, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key)
end
def resource_model