How to acccess urls defined in a plugin publicly?

I added below code in plugin.rb file.

  DiscourseRatings::Engine.routes.draw do
    post "/rate" => "rating#rate"
    post "/remove" => "rating#remove"
    get '/getratings' => 'rating#getRatings'

I am able to use get “ratings” url which is /rating/getratings in AJAX Call. but when i use this url with domain name e.g 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
likewise i want to access plugins get urls.

Could you tell me how to define urls in a plugin which are accessible publicly ?

1 Like

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

1 Like

I am able to access newly defined get url which is get “/getbadges” => "categories#getBadges"

I defined GET url which is get “/getbadges” => “categories#getBadges” in routes.rb file.

and below getBadges method in categories_controller.rb file

def getBadges
	json_data = {"name":"siddhu"}
	render json: json_data

I ran local disocurse instance and try to access defined get url http://localhost:9292/getbadges.
I am able to acess this get url but same thing i did in GitHub - siddhudhangar/discourse-ratings plugin. here it is not working, Can you help me out for solving this issue ?

Below i gave my github url, here you can check my code and let me know if i have made any mistakes.

I am able to access all GET url which i defined into the plugin. Issue is resolved now. thanks.