Skip to content

Commit a159dea

Browse files
committed
set initial values on topic creation
1 parent 68592cf commit a159dea

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

plugin.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Engine < ::Rails::Engine
2222
end
2323

2424
#############################################################################
25+
# /config/routes.rb
2526

2627
CommunityCustomFields::Engine.routes.draw do
2728
put '/:topic_id' => 'custom_fields#update'
@@ -62,4 +63,10 @@ def update
6263
add_to_serializer(:topic_view, :custom_fields) do
6364
object.topic.custom_fields.slice('assignee_id', 'status')
6465
end
66+
67+
on(:topic_created) do |topic, params, user|
68+
topic.custom_fields["assignee_id"] ||= nil # or any default value
69+
topic.custom_fields["status"] ||= "new"
70+
topic.save_custom_fields
71+
end
6572
end

0 commit comments

Comments
 (0)