Remove the create action from CommentableActions
We were only using it in one place: the debates controller. All the
other controllers including CommentableActions were overwriting this
action, except the ones in the admin area, where creating proposals,
debates or investments isn't possible.
Note this means that, most of the times, we weren't tracking events
creating a resource.
Also note that since, as mentioned in commit 3752fef6b, there are no
geozones in the debates form, we don't have to load them when creating a
debate fails due to validation rules.
This commit is contained in:
@@ -44,21 +44,6 @@ module CommentableActions
|
|||||||
@resources = @search_terms.present? ? resource_relation.search(@search_terms) : nil
|
@resources = @search_terms.present? ? resource_relation.search(@search_terms) : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
|
||||||
@resource = resource_model.new(strong_params)
|
|
||||||
@resource.author = current_user
|
|
||||||
|
|
||||||
if @resource.save
|
|
||||||
track_event
|
|
||||||
redirect_path = url_for(controller: controller_name, action: :show, id: @resource.id)
|
|
||||||
redirect_to redirect_path, notice: t("flash.actions.create.#{resource_name.underscore}")
|
|
||||||
else
|
|
||||||
load_geozones
|
|
||||||
set_resource_instance
|
|
||||||
render :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ class DebatesController < ApplicationController
|
|||||||
helper_method :resource_model, :resource_name
|
helper_method :resource_model, :resource_name
|
||||||
respond_to :html, :js
|
respond_to :html, :js
|
||||||
|
|
||||||
|
def create
|
||||||
|
@debate = Debate.new(debate_params)
|
||||||
|
@debate.author = current_user
|
||||||
|
|
||||||
|
if @debate.save
|
||||||
|
track_event
|
||||||
|
redirect_to debate_path(@debate), notice: t("flash.actions.create.debate")
|
||||||
|
else
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def index_customization
|
def index_customization
|
||||||
@featured_debates = @debates.featured
|
@featured_debates = @debates.featured
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user