Developing Discourse Plugins - Part 5 - Add an admin interface

I’ve recently done this in the Lattice plugin, where I was able to get this to go without specifying a resource field.

# lattice-route-map.js.es6
export default function() {
  this.resource('lattice', { path: '/lattices/:id' })

Fun fact: Discourse does pattern matching on filenames to determine what to cook into the routes. Anything matching /route-map$/ will attempt to get baked into the router.


Does this still work with Ember v2.10?:

It should! Is it not working for you?

Hi Robin,
It does work but I was suspicious that this might not work since you switched to Ember v2.10 all resources in the app-route-map were changed to routes.


@gdpelican, thanks a million for advertising this! Your plugin is the only example I found about how to create a public route (non-admin) from a plugin.


Seems like a common enough plugin use case that it would be really nice to put it into a plugin helper, something like

define_route :get, '/lattices', 'lattices#index'
define_route :post, '/lattices', 'lattices#create'

Rather than having plugin authors care about rails engines and mounting and whatnot.

If I get back to having some time to work on Discourse, I may do that :slight_smile:


same issue with the title, renaming to client.en.yml has worked for me :slight_smile:

My “show purple tentacle” (I’ve used other namings) button is not displaying.


{{#if imgVisible}}
  <div class='tentacle'>
    <img src="">

<div class='buttons'>
  {{d-button label="" action="showImg" icon="eye"}}

I rm -rf tmp; bundle exec rails s when I start the server. I’ve compared the code with eviltrout’s repo and all seems alright. What could be the issue? Thanks!

The auto-loading of handlebars templates (and other ember related things) is quite sensitive to file names - it might be as simple as adding plugins- to the beginning of the file name so it matches the instructions closer.

If that doesn’t work, I’d suggest trying the tutorial again, but using exactly the plugin & file names specified in the instructions. Then if that works adapt it from there


it has worked like magic!

1 Like

Just so I can update the original post, what steps were required to fix this tutorial?

If it was what I said, then no changes, other than maybe a message to say how important it is that file names are exactly correct

I don’t know how far things should go for teaching prerequisite “basic knowledge”. But I think a lot of the troubles are when it is not only the first Discourse plugin but also an early venture into Ruby / Ember

That is, an unfamiliarity with the conventions that do “magic”. When structure and naming look like arbitrary is OK but it isn’t it can be a pain to figure out what’s wrong.

The “this can be whatever, this must be” stuff.


Work for me!

1. Code

2. Result


Glad it worked, but It is always better to post code than pictures of code.


Thanks for reply
original post have all these code,
it’s not necessary for me to post code again.

The purpose of these picture is to show it work, give viewer a big picture view
(not for viewer to copy&paste)
(code in code editor have nicer code highlight)

If anyone runs into a testing error, I had to add id="show-tentacle" to the button component to get the tests to pass in part 6 of the tutorial:

<div class="buttons">
  {{d-button label="" action="showTentacle" icon="eye" id="show-tentacle"}}

I found the Ember routing didn’t work until I commented out path: '/plugins' in the route-map file:

export default {
  resource: 'admin.adminPlugins',
  // path: '/plugins',
  map () {

For some reason Ember was expecting a route at adminPlugins/watch-mute not at adminPlugins/plugins/watch-mute. Is this something I did wrong upstream in the routing call chain, or has something changed in the way Discourse/Ember handles these?

The linked discourse-akismet plugin doesn’t have that admin UI/tab/code btw. The good news is that another plugin,, does have it.

1 Like

11 posts were split to a new topic: How to execute server-side code when clicking a button?