/thredded

A rails forum engine

Primary LanguageRubyMIT LicenseMIT

Thredded is a rails 4+ forum/messageboard engine. Its goal is to be as simple and feature rich as possible.

If you're looking for variations on a theme - see Discourse, Forem, Tectura or Heterotic Beast. The last two are forks from Rick Olsen and Courtenay's Altered Beast. Of those it should be noted that Forem is an engine - not a standalone app.

Click here to lend your support to: Thredded and make a donation at pledgie.com !

If you are so inclined, donating to the project will help aid in its development

Installation

Add the gem to your Gemfile:

gem 'thredded'

Add a thredded initializer to your parent app by running the install generator. The initializer has detailed descriptions of all of the configuration options.

rails generate thredded:install

Copy the migrations over to your parent application and migrate:

rake thredded:install:migrations db:migrate db:test:prepare

Mount the thredded engine in your routes file:

mount Thredded::Engine => '/forum'

Development dependencies

  • PostgreSQL & MySQL - brew install postgres mysql

Background Job Requirements

This gem has several gem agnostic background jobs. Currently resque, sidekiq, delayed_job, and a threaded in-memory queue are supported thanks to Richard Schneeman's Q gem. The configuration detailed above allows you to specify which job queue you prefer with Thredded.queue_backend. The available options are one of the following symbols - :threaded_in_memory_queue, :sidekiq, :resque, or :delayed_job.

When using the threaded in-memory queue you may optionally update its log-level for more granular debugging with the Thredded.queue_memory_log_level setting.

When running the app in a test environment you may want to set your queue to run the jobs inline. In your config you may want to set the option based on environment. EG:

Thredded.queue_inline = Rails.env.test?

Get Your Parent App Ready

There are a few things you need in your app to get things looking just right.

  1. Add a to_s method to your user model. The following example assumes a column in my user model called name:
class User < ActiveRecord::Base
  def to_s
    name
  end
end
  1. Ensure you have a view layout that thredded will wrap around its views.

A couple of notes with regards to your layout.

  • When using route helpers -- eg: new_session_path, et al -- make sure to prepend main_app to the helper: main_app.new_session_path as rails engines like thredded will not know about those routes' existence unless explicitly told so.
  • As noted above, by default thredded will look for a layout file in your application called thredded.html.erb. If you would like to use something else, like your main application layout, you may change it to that in your initializer.
  • The chosen layout has two content_tags available to yield - :thredded_page_title and :thredded_page_id. The views within thredded pass those up through to your layout if you would like to use them. Example layout:
<html>
  <head>
  <title>My Application | <%= yield :thredded_page_title %></title>
  </head>
  <body id="<%= yield :thredded_page_id %>">
    <%= yield %>
  </body>
</html>