Updating and saving topic on button press results in 404 not found


(Janno Liivak) #1

I have a plugin which places a button after main buttons. When pressing a button I would like to update topic and save it. But topic.save(props); results in 404 not found. Debugging reveals that Discourse is trying to PUT at /topics/:topic_id instead of /t/:topic_id. Is there something I’m doing wrong or is it a bug?


(Alan Tan) #2

Hmm do you know which part of the code base is trying to hit the /topics/:topic_id route?


(Janno Liivak) #3

Yes. It’s a rest adapter’s pathFor(store, type, findArgs) {…}. It will be called through store model’s update() method (which is called from rest model’s update() method.

This is my plugin where I get this behaviour:


(Janno Liivak) #4

I have a feeling that I’m doing something wrong here (namely in mu plugin code which I pointed out above). Should I do rather somethink like:

Discourse.Topic.update(topic, props);

No? Yes?
Kind of works … no error with this change … but nothing get’s saved also into the database :frowning:

Can somebody please point me a right direction? …Please


(Janno Liivak) #5

I kind of feel like I’m having a conversation with myself :wink:

Anyway … Found a missing logic in my plugin code, BUT … also had to change Discourse. Created PR Create correct topic path for REST adapter by jannolii · Pull Request #4698 · discourse/discourse · GitHub