User page with custom data from external DB

Totally possible, if you’re willing to persevere a little bit.

It is, but connecting Discourse to two databases makes me wince a bit.

It might help if you understood how all the bits of Discourse link together. You basically have to think of Discourse as two seperate applications - the frontend, running an Ember app, and the backend, running a Rails app.

The frontend and the backend talk through an API, but otherwise, they’re basically entirely self contained.

So whatever you end up doing, you’re going to have to write a REST API to get the data from the backend to the frontend *. So now the question becomes, are you going to want to do anything on the backend with this data? (Such as assigning people to groups, or awarding badges, based on it.) Or is it just stuff you want to show on the frontend?

If you do want to to do stuff on the backend with it, you’ll have to have that data in some form on the backend (so this is where you’d connect to your MySQL db from ruby) and then write your API in ruby to actually get the data to the frontend.

If you don’t, then you might as well write your API in whatever language you feel most comfortable, and then query that from the frontend.

* Unless its very simple data, in which case it’s easiest to pass it to the frontend by adding it as a user.custom_fields, which you can then access through the user object in your plugin outlet.

There should be, soon:

Only server-side changes (so generally those done in Ruby). Generally anything changed client side just needs a refresh of the page (although sometimes you need to kill your rails server and do a rm -rf tmp/).

Yes, almost certainly. I’m always stumbling across topics on here which I realised would’ve helped me out massively when I was trying to figure out how to do something (both at the beginning, and more recently).

The Rails and Ember guides have a wealth of general information, especially with the latter when it comes to this:

And there’s this wonderful topic:

Good luck, have fun, and I’ve found there’s nothing that can replace a good ol’ bit of messing about just to see what happens! :smile:

7 Likes