Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

thredded

> 后端框架
Open source

The best Rails forums engine ever.

1.6K stars0 likes1 views
WebsiteGitHub

About

The best Rails forums engine ever.

Thredded

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

Some of the features currently in Thredded:

  • Markdown (default) and / or BBCode post formatting, with onebox and <spoiler> / [spoiler] tag support.
  • (Un)read posts tracking.
  • Email notifications, topic subscriptions, @-mentions, per-messageboard notification settings.
  • Private group messaging.
  • Full-text search using the database.
  • Pinned and locked topics.
  • List of currently online users, for all forums and per-messageboard.
  • Flexible permissions system.
  • Basic moderation.
  • Lightweight default theme configurable via Sass.

Thredded works with SQLite, MySQL (v5.6.4+), and PostgreSQL. Thredded has no infrastructure dependencies other than the database and, if configured in the parent application, the ActiveJob backend dependency such as Redis. Currently only MRI Ruby 3.1+ is supported. We would love to support JRuby and Rubinius as well.

If you're looking for variations on a theme - see Discourse. However, it is a full rails application and not an engine like Thredded.

Table of Contents

  • Installation
    • Creating a new Rails app with Thredded
    • Adding Thredded to an existing Rails app
    • Upgrading an existing install
    • Migrating from Forem
  • Rails compatibility
  • Views and other assets
    • Standalone layout
    • Application layout
      • Reference your paths so that Thredded can find them
      • Add Thredded styles
      • Add Thredded JavaScripts (Sprockets)
      • Add Thredded JavaScripts (Webpack)
    • User profile page
    • Customizing views
      • View hooks
    • Theming
      • Styles
  • Email and other notifications
    • Enabling auto-follow
  • I18n
  • Permissions
    • Permission methods
      • Reading messageboards
      • Posting to messageboards
      • Messaging other users (posting to private topics)
      • Moderating messageboards
      • Admin permissions
    • Default permissions
    • Handling "Permission denied" and "Not found" errors
  • Moderation
    • Disabling moderation
  • Plugins
  • Development
    • Testing
    • Ruby
    • JavaScript
    • Testing with all the databases and Rails versions locally.
    • Developing and Testing with Docker Compose

Installation

Creating a new Rails app with Thredded

[!CAUTION] Please add thredded_create_app is currently out of date and needs contributors to fix it - it won't work with the latest thredded. See https://github.com/thredded/thredded_create_app if you can contribute.

View the outdated instructions

Thredded provides an app generator that will generate a Rails app with Thredded, Devise, SimpleForm, RSpec, PostgreSQL, and a basic theme and navigation that is configured to work out of the box.

bash
gem install thredded_create_app
thredded_create_app path/to/myapp

See thredded_create_app --help and the thredded_create_app repo to learn about the various options.

Then, see the rest of this Readme for more information about using and customizing Thredded.

Adding Thredded to an existing Rails app

Add the gem to your Gemfile:

ruby
gem 'thredded', '~> 1.2'

Add the Thredded [initializer] to your parent app by running the install generator.

bash
rails generate thredded:install

Thredded needs to know the base application User model name and certain columns on it. Configure these in the initializer installed with the command above.

Then, copy the migrations over to your parent application and migrate:

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

Mount the thredded engine in your routes file:

ruby
mount Thredded::Engine => '/forum'

You also may want to add an index to the user name column in your users table. Thredded uses it to find @-mentions and perform name prefix autocompletion on the private topic form. Add the index in a migration like so:

ruby
DbTextSearch::CaseInsensitive.add_index(
    connection, Thredded.user_class.table_name, Thredded.user_name_column, unique: true)

Upgrading an existing install

  1. To upgrade the initializer:
bash
rails g thredded:install

But then compare this with the previous version to decide what to keep.

  1. To upgrade the database (in this example from v0.11 to v0.12):
bash
# Note that for guaranteed best results you will want to run this with the thredded gem at v0.12
cp "$(bundle show thredded)"/db/upgrade_migrations/20170420163138_upgrade_thredded_v0_11_to_v0_12.rb db/migrate
rake db:migrate

Migrating from Forem

Are you currently using Forem? Thredded provides a migration to copy all of your existing data from Forem over to Thredded.

Rails compatibility

Rails JS frameworks Latest Thredded
Rails 7.2 - Rails 8.1 Turbo Thredded 2.0
Rails 7.0 - Rails 8.0 rails-ujs , jquery-ujs, and/or Turbolinks Thredded 1.2
Rails 6.0 - rails 6.1 rails-ujs , jquery-ujs, and/or Turbolinks Thredded 1.1
Rails 5.2 rails-ujs , jquery-ujs, and/or Turbolinks Thredded 1.0.1
Rails 4.2 rails-ujs , jquery-ujs, and/or Turbolinks Thredded 0.16.16

Views and other assets

Standalone layout

By default, thredded renders in its own (standalone) layout.

When using the standalone thredded layout, the log in / sign out links will be rendered in the navigation. For these links (and only for these links), Thredded makes the assumption that you are using devise as your auth library. If you are using something different you need to override the partial at app/views/thredded/shared/nav/_standalone.html.erb and use the appropriate log in / sign out path URL helpers.

You can override the partial by copying it into your app:

bash
mkdir -p app/views/thredded/shared/nav && cp "$(bundle show thredded)/$_/_standalone.html.erb" "$_"

Application layout

You can also use Thredded with your application (or other) layout by setting Thredded.layout in the initializer.

In this case, you will need to reference your paths/routes carefully and pull in thredded assets (styles and javascript):

Reference your paths so that Thredded can find them

In your layout you will probably have links to other paths in your app (e.g. navigation links). For any url helpers (like users_path or projects_path or whatever) will need to have main_app. prefixed to them so that they can be found from thredded (main_app.users_path will work from both thredded and your app).

Add Thredded styles

In this case, you will also need to include Thredded styles and JavaScript into the application styles and JavaScript.

Add thredded styles to your application.scss:

scss
@import "thredded";

Thredded wraps the views in a container element that has a max-width and paddings by default. If your app layout already has a container element that handles these, you can remove the max-width and paddings from the Thredded one by adding this Sass snippet after @import "thredded";:

scss
.thredded--main-container {
  // The padding and max-width are handled by the app's container.
  max-width: none;
  padding: 0;
  @include thredded-media-tablet-and-up {
    padding: 0;
  }
}

See below for customizing the styles via Sass variables.

Add Thredded JavaScripts (Sprockets)

Include thredded JavaScripts in your application.js:

javascript
//= require thredded

Thredded is fully compatible with deferred and async script loading.

Add Thredded JavaScripts (Webpack)

You can also include Thredded JavaScript into your webpack pack.

First, run bundle exec rails webpacker:install:erb.

Then, add an app/javascript/thredded_imports.js.erb file with the following contents:

erb
<%= Thredded::WebpackAssets.javascripts %>

Finally, add the following to your app/javascript/packs/application.js:

javascript
require('thredded_imports.js');

Note that you must use require (not import) because Thredded JavaScript must be run after Turbo is started. has been called. This is because Webpack places import calls before the code in the same file (unlike require, which are placed in the same order as in the source).

Alternative JavaScript dependencies
Timeago version

By default, thredded loads timeago.js.

If you'd like to use jquery.timeago or rails-timeago instead, run this command from your app directory:

bash
mkdir -p app/assets/javascripts/thredded/dependencies/
echo '//= require jquery.timeago' > app/assets/javascripts/thredded/dependencies/timeago.js

You will also need to adjust the //= require statements for timeago locales if your site is translated into multiple languages. For jquery.timeago, these need to be require after thredded/dependencies but before thredded/thredded. E.g. for Brazilian Portuguese with jquery.timeago:

javascript
//= require thredded/dependencies
//= require locales/jquery.timeago.pt-br
//= require thredded/thredded

Thredded page title and ID

Thredded views also provide 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.

User profile page

Thredded does not provide a user's profile page, but it provides a partial for rendering the user's recent posts in your app's user profile page. Here is how you can render it in your app:

erb
<%= Thredded::ApplicationController.render partial: 'thredded/users/posts', locals: {
      posts: Thredded.posts_page_view(scope: user.thredded_posts.order_newest_first.limit(5),
                                      current_user: current_user) } %>

The user above is the user whose posts are rendered, and current_user is the user viewing the posts or nil. The policy scopes that limit the posts to the ones current_user can see are applied automatically.

The code above uses the ApplicationController.render method introduced in Rails 5. If you're using Rails 4, you will need to add the backport_new_renderer gem to use it.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyforumsmessage-boardrailsrails-engine

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架