Skip to content
sibblingz edited this page Feb 8, 2012 · 8 revisions

The configuration options for Forem are explained beneath. These usually live in config/initializers/forem.rb.

User class

To specify the class that represents users in your system, use the user_class option:

Forem.user_class = "User"

The user class's instances should respond to 'to_s' for the user's name, and 'email' for use by Gravatar.

NOTE: previously this option accepted a Class object, but that has been deprecated due to the issue explained in #88.

ActionMailer Config

The mailer view templates don't have a 'request' object, so you need to specify a default host that it can use to generate the full url's for the emails. Something like this:

config.action_mailer.default_url_options = { :host => "example.com" }

Theme

For information on theming, please see the "Theming" page

User profile links

To change the username text on each post to be a link to the User's profile use the following configuration:

Forem.user_profile_links = true

Then you just need to make sure that you have routes configured for your user model to show the desired profile page. If, for example, you have a model called User then this feature expects either the user_path or user_url helper to be defined.

The simplest way you can define these in your routes is like this:

match 'users/:id', :to => "users#show", :as => :user

Alternatively, use a resources line, as it defines these helpers automatically for you:

resources :users

Avatars

By default Forem uses Gravatar for displaying avatar images for post authors. If the user object returned by forem_user responds to email, this is queried automatically. If a user does not have a Gravatar image associated with their email address they will get the default Gravatar image:

default gravatar

The behavior of the default image can be configured with two configuration options.

Default gravatar theme

To set a default Gravatar theme, use the .default_gravatar method:

Forem.default_gravatar = 'mm'

Default gravatar image

To set a default image, use the .default_gravatar_image method:

Forem.default_gravatar_image = 'gravatar_default.png'

When a relative path is given, it will be expanded into the absolute URL required by Gravatar with information from the request that was made and Rails's configuration. For example, given the above method call, in development this would be expanded to something like:

http://localhost:3000/images/gravatar_default.png

Passing an absolute URL to .default_gravatar_image or .default_gravatar is roughly equivalent.

More information

More information about Gravatar can be found on this page about Gravatar image requests.

Clone this wiki locally