The discussion revolves around accessing URLs defined in a Discourse plugin publicly. Siddhu_Dhangar initially faced an issue where defined URLs were not accessible publicly, receiving a “page doesn’t exist” error. After some guidance from fzngagan to look into Rails routes and engines, Siddhu_Dhangar discovered the solution by defining GET URLs in the routes.rb file and creating corresponding methods in the controller. For example, defining get "/getbadges" => "categories#getBadges" and creating a getBadges method in the categories_controller.rb file. After implementing this solution, Siddhu_Dhangar was able to access all defined GET URLs in the plugin publicly, resolving the issue.
DiscourseRatings::Engine.routes.draw do
post "/rate" => "rating#rate"
post "/remove" => "rating#remove"
get '/getratings' => 'rating#getRatings'
end
I am able to use get “ratings” url which is /rating/getratings in AJAX Call. but when i use this url with t2.metastudio.org domain name e.g https://t2.metastudio.org/rating/getratings. discourse says
Oops! That page doesn’t exist or you may have to login to see it!
For example i can access categories data in using following url which is https://t2.metastudio.org/categories.json
likewise i want to access plugins get urls.
Could you tell me how to define urls in a plugin which are accessible publicly ?
Basically, you need to look up how the rails routes and engines work. Routes map the urls with rails controllers’ actions. Also do refer to this guide. Its my favourite discoursd tutorial. How to create a Discourse plugin – kleinfreund.de