# Thredded (the gem / rails engine) ## Installation Add the gem to your Gemfile: ```ruby gem 'thredded' ``` Add an initializer to your app: `config/initializers/thredded.rb` ```ruby Thredded.user_class = 'User' Thredded.email_incoming_host = 'incoming.example.com' Thredded.email_from = 'no-reply@example.com' Thredded.email_outgoing_prefix = '[Thredded] ' Thredded.user_path = ->(user){ "/path/to/where/you/show/#{user}" } Thredded.file_storage = :file # or :fog Thredded.asset_root = 'http://assets.website.com/assets' # where important things, like emojis, might live Thredded.layout = 'thredded' # looks for `app/views/layouts/thredded.html.erb` Thredded.avatar_default = 'mm' # or other gravatar defaults or URL to an image ``` 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' ``` ## Get Your 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`: ```ruby class User < ActiveRecord::Base def to_s name end end ``` 2. 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