The best Rails forums engine ever.
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:
<spoiler> / [spoiler] tag support.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.
View the outdated instructions[!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.
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.
gem install thredded_create_app
thredded_create_app path/to/myappSee 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.
Add the gem to your Gemfile:
gem 'thredded', '~> 1.2'Add the Thredded [initializer] to your parent app by running the install generator.
rails generate thredded:installThredded 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:
rake thredded:install:migrations db:migrate db:test:prepareMount the thredded engine in your routes file:
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:
DbTextSearch::CaseInsensitive.add_index(
connection, Thredded.user_class.table_name, Thredded.user_name_column, unique: true)rails g thredded:installBut then compare this with the previous version to decide what to keep.
# 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:migrateAre you currently using Forem? Thredded provides a migration to copy all of your existing data from Forem over to Thredded.
| 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 |
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:
mkdir -p app/views/thredded/shared/nav && cp "$(bundle show thredded)/$_/_standalone.html.erb" "$_"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):
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).
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:
@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";:
.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.
Include thredded JavaScripts in your application.js:
//= require threddedThredded is fully compatible with deferred and async script loading.
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:
<%= Thredded::WebpackAssets.javascripts %>Finally, add the following to your app/javascript/packs/application.js:
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).
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:
mkdir -p app/assets/javascripts/thredded/dependencies/
echo '//= require jquery.timeago' > app/assets/javascripts/thredded/dependencies/timeago.jsYou 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:
//= require thredded/dependencies
//= require locales/jquery.timeago.pt-br
//= require thredded/threddedThredded 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.
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:
<%= 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.
No open issues yet, or sync has not completed.