Application level configuration.

Original Author

Christopher J. Bottaro

Merb Port

Jacques Crocker

Accessing the AppConfig object

After installing this plugin, the AppConfig object will be global available. Entries are accessed via object member notation:


Nested entries are supported:


Common config file

Config entries defined in


will be available to all environments.

Environment specific config files

You can have environment specific config files. Environment specific config entries take precedence over common config entries.

Example development environment config file:


Example production environment config file:


Embedded Ruby (ERB)

Embedded Ruby is allowed in the configuration files.  See examples below.

Easy Stylesheets and Javascripts

You can also define your javascripts and stylesheets using AppConfig

Merb.root/config/javascripts.yml Merb.root/config/stylesheets.yml

  • prototype-bundle:

    • prototype

    • scriptaculous

  • jquery-bundle:

    • jquery

    • jquery.ui/tabs

  • components-bundle:

    • components/blah

    • components/blah2

This will include all the javasciprt files listed when running the helper “javascripts”, and on prod, it will bundle them up by key (prototype-bundle.js, jquery-bundle.js, components-bundle.js)

If you want to see something really awesome, try this:

  • jquery-bundle:

    • jquery

    • jquery.ui/*

    • jquery.plugins/*

On the first request this will grab ALL the files from these folders (using Dir), and bundle them on. On subsequent requests, it will use the bundle directly

In your application layout, just include the calls to <%= stylesheets %> <%= javascripts %>


Consider the two following config files.


size: 1


size: 2
computed: <%= 1 + 2 + 3 %>
  size: 3
  servers: [ {name:}, {name:} ]

Notice that the environment specific config entries overwrite the common entries.

AppConfig.size -> 2
AppConfig.server ->

Notice the embedded Ruby.

AppConfig.computed -> 6

Notice that object member notation is maintained even in nested entries.

AppConfig.section.size -> 3

Notice array notation and object member notation is maintained.

AppConfig.section.servers[0].name ->
AppConfig.section.servers[1].name ->