# How to acccess urls defined in a plugin publicly?

**URL:** https://meta.discourse.org/t/how-to-acccess-urls-defined-in-a-plugin-publicly/163615
**Category:** Support
**Created:** [September 10, 2020, 1:19pm UTC](https://meta.discourse.org/t/how-to-acccess-urls-defined-in-a-plugin-publicly/163615 "2020-09-10T13:19:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Siddhu\_Dhangar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/siddhu_dhangar/32/123849_2.png) [@Siddhu\_Dhangar](https://meta.discourse.org/u/Siddhu_Dhangar)
#### Post date: [September 10, 2020, 1:19pm UTC](https://meta.discourse.org/t/how-to-acccess-urls-defined-in-a-plugin-publicly/163615/1 "2020-09-10T13:19:38Z")

</div>

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'
  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 ?

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [September 15, 2020, 4:36am UTC](https://meta.discourse.org/t/how-to-acccess-urls-defined-in-a-plugin-publicly/163615/2 "2020-09-15T04:36:32Z")

</div>

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](https://kleinfreund.de/how-to-create-a-discourse-plugin/)

---

<div class="post-metadata">

### Author: ![Siddhu\_Dhangar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/siddhu_dhangar/32/123849_2.png) [@Siddhu\_Dhangar](https://meta.discourse.org/u/Siddhu_Dhangar)
#### Post date: [September 16, 2020, 11:25am UTC](https://meta.discourse.org/t/how-to-acccess-urls-defined-in-a-plugin-publicly/163615/3 "2020-09-16T11:25:08Z")

</div>

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

 ![Screenshot from 2020-09-16 16-45-14](https://global.discourse-cdn.com/meta/original/3X/a/6/a6e94f755e4ffca22d95283d5b22a34086605337.png)

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
end

```

I ran local disocurse instance and try to access defined get url [http://localhost:9292/getbadges](http://localhost:9292/getbadges).  
I am able to acess this get url but same thing i did in [GitHub - siddhudhangar/discourse-ratings · GitHub](https://github.com/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.  
[https://github.com/siddhudhangar/discourse-ratings](https://github.com/siddhudhangar/discourse-ratings)

---

<div class="post-metadata">

### Author: ![Siddhu\_Dhangar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/siddhu_dhangar/32/123849_2.png) [@Siddhu\_Dhangar](https://meta.discourse.org/u/Siddhu_Dhangar)
#### Post date: [September 17, 2020, 4:15am UTC](https://meta.discourse.org/t/how-to-acccess-urls-defined-in-a-plugin-publicly/163615/4 "2020-09-17T04:15:08Z")

</div>

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