Skip to content
Brad Fults edited this page Oct 18, 2011 · 1 revision

You can configure Boxer to include a list of Ruby modules in every box.

Boxer.configure do |config|
  config.box_includes = [MyMethods, SomeOtherMethods]
end

This is especially useful in Rails for URL generation methods:

Boxer.configure do |config|
  config.box_includes = [Rails.application.routes.url_helpers]
end

Now you can use those URL generation methods inside of all your boxes without thinking twice:

Boxer.box(:user) do |box, user|
  {
    :name => user.name,
    :url  => user_path(user),
  }
end

For more, see Using Boxer with Rails.

Clone this wiki locally