Getting Started with Discourse

productivityMay 25, 2013Dotby Justin Gordon

Looking for a great open source example of a production quality rails, emberjs, and single-page-application project? Check out Discourse.

Discourse is the 100% open source, next-generation discussion platform built for the next decade of the Internet.

Here's a great example of the Discourse code in action: Is it better for Discourse to use JavaScript or CoffeeScript?

Production Quality, not a Tutorial

Note, this is an example of a production quality application, rather than a useful tutorial sample application. What's the difference? The Discourse codebase is the real deal, including all the gory details, such as performance optimizations. If you want a superb sample rails application, check out Rails Tutorial, 2nd Ediition and read the book Ruby on Rails Tutorial, Learn Web Development with Rails, Michael Hartl. There's even an interesting discussion on the Discourse blog about Discourse as Your First Rails App, which it shouldn't be.

That being said, the Discourse code base is probably as good as or, in many cases, better than what you'll find in many software-as-a-service companies. It's no secret that public scrutiny of popular open source code really raises the bar on quality. Consequently, if you're a serious and experienced Rails developer, it's worth your time to install the source of discourse and explore and run it. I just did that and I'm impressed.

Why Explore Discourse's Source?

  1. Example of EmberJs Single-Page-Application.
  2. Design decisions are discussed at meta.discourse.org, such as Is it better for Discourse to use JavaScript or CoffeeScript?
  3. Solid project, from code quality to organization.
  4. Co-Founded by Jeff Atwood, who created Stack Overflow. Jeff wrote a article introducing the discourse project: Civilized Discourse Construction Kit.

Setup Tips

Basically, there's a few dependencies to install, some of which you probably already have installed, such as Postgres and Redis. The main gotcha I faced was to make sure that you run the postgres instructions for creating the development database, rather than using the rake task. Then you can install the seed data:

psql -d discourse_development < pg_dumps/development-image.sql

The rake task to do rake db:seed_fu does not install the sample data, but rather some tiny bit of "seed" data (like post action types).

Once you have the test data installed, then run these commands.

bundle install # Yes, this DOES take a while. No, it's not really cloning all of rubygems :-)
rake db:migrate
rake db:test:prepare
rake db:seed_fu
bundle exec rspec # All specs should pass

You should have installed MailCatcher, so that you don't have to configure any smtp server. Then you just have to visit http://localhost:1080 to see the mail messages that Discourse sends.

Then to run the Discourse application (assuming postgres and redis are running) open up two tabs. Cd each to the disource directory.

bundle exec rails server
bundle exec sidekiq
bundle exec clockwork config/clock.rb

Or, install foreman (gem install foreman) and run (runs the Procfile).

export PORT=3000
export RAILS_ENV=development
foreman start

If you got this working, you'll see this: image1

Links

Closing Remark

Could your team use some help with topics like this and others covered by ShakaCode's blog and open source? We specialize in optimizing Rails applications, especially those with advanced JavaScript frontends, like React. We can also help you optimize your CI processes with lower costs and faster, more reliable tests. Scraping web data and lowering infrastructure costs are two other areas of specialization. Feel free to reach out to ShakaCode's CEO, Justin Gordon, at [email protected] or schedule an appointment to discuss how ShakaCode can help your project!
Are you looking for a software development partner who can
develop modern, high-performance web apps and sites?
See what we've doneArrow right