EDIT
Thanks, I tried the above code , and it worked.
Thankyou
I was trying something on similar lines
Here they watch the topic_guuid
Then they get that value in before_create_topic event
I am able to save the custom model to topic, but when I try to edit the first post of topic, it throws error.
If I comment out the PostRevisor code, the error dosent come. So I think it is due to PostRevisor only.
I do not have to do anything if value changes, I just need to get the value from UI and use it in plugin.rb to save it to topic. And it throws only in when editing the first post of topic. In the postrevisor class, I kept breakpoint to see
def update_topic
Topic.transaction do
PostRevisor.tracked_topic_fields.each do |f, cb|
if !@topic_changes.errored? && @fields.has_key?(f)
cb.call(@topic_changes, @fields[f])
end
end
unless @topic_changes.errored?
@topic_changes.check_result(@topic.save(validate: @validate_topic))
end
end
end
Here in the PostRevisor.tracked_topic_fields array, the value for testid is “nil”.
Here is the snippet. When it comes to testid, it throws error
{:title=>#<Proc:0x007f8e5e3f9258@/Users/santosh/discourse/lib/post_revisor.rb:65>, :category_id=>#<Proc:0x007f8e5ad8b130@/Users/santosh/discourse/lib/post_revisor.rb:70>, :tags=>#<Proc:0x007f8e5ad8a438@/Users/santosh/discourse/lib/post_revisor.rb:75>, :tags_empty_array=>#<Proc:0x007f8e5ad8a348@/Users/santosh/discourse/lib/post_revisor.rb:87>, :featured_link=>#<Proc:0x007f8e5ad895b0@/Users/santosh/discourse/lib/post_revisor.rb:98>, :testid=>nil}