Skip to content

Commit e46a491

Browse files
committed
auto-enable created page types
1 parent 1db1813 commit e46a491

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/controllers/content_controller.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def new
118118
end
119119

120120
@content.save!
121+
122+
# If the user doesn't have this content type enabled, go ahead and automatically enable it for them
123+
current_user.user_content_type_activators.find_or_create_by(content_type: @content.class.name)
124+
121125
return redirect_to edit_polymorphic_path(@content)
122126
else
123127
return redirect_to(subscription_path, notice: "#{@content.class.name.pluralize} require a Premium subscription to create.")
@@ -186,6 +190,9 @@ def create
186190
end
187191
end
188192

193+
# If the user doesn't have this content type enabled, go ahead and automatically enable it for them
194+
current_user.user_content_type_activators.find_or_create_by(content_type: content_type.name)
195+
189196
successful_response(content_creation_redirect_url, t(:create_success, model_name: @content.try(:name).presence || humanized_model_name))
190197
else
191198
failed_response('new', :unprocessable_entity, "Unable to save page. Error code: " + @content.errors.to_json.to_s)

0 commit comments

Comments
 (0)