Monday, February 11, 2008

Merb Monday: "That's the spirit"

Tidbits from #merb for the week of Feb 4 - Feb 10.

A lot of the conversation this week revolved around the pre 0.9 release. Many of the questions involved bugs or other issues that one can expect in a pre-release. In general I didn't include them as they will quickly be outdated and likely be of little on going value.

Q: How do I install (freeze) gems within my application?

A: Navigate to the root of your Merb application.

gem install foo -i gems
In your merb.yml file include a line:
dependency "foo"
(Answer by wycats)

Q: How do I support a new MIME type? Say for an Atom feed.

Replace application/x-atom with whatever the correct header for atom is then make a template: foo.atom.erb

In your controller, use:
provides :atom
(Answer by ezmobius)

Q: Where could I define a constant which would then be accessible in different views, but should have a different value depending on the environment merb is running in?

A: config/environment/*.rb where * represents the desired environment, for example development.rb.

Q: How do I find the current controller and action in the view?

A: In a helper you could create the two following methods.
def controller_name

def action_name
(Answer by slurry)

Q: What happened to MERB_ENV?

A: Merb's application constants have been re-factored as follows:
Old constant : New method

MERB_FRAMEWORK_ROOT : Merb.framework_root
MERB_ROOT : Merb.root
MERB_VIEW_ROOT : Merb.view_path
MERB_SKELETON_DIR : Merb.skeleton_path
MERB_LOGGER : Merb.logger
MERB_PATHS : Merb.load_paths
MERB_ENV : Merb.environment
(Answer by slurry)

Q: Is there a way to list all the generators available?

A: ruby ./script/generate

Q: Where is the source now?

A: The Merb project has switched from using SVN to Git for source code management. With that change the source is now at Github. Specifically you will want to use wycats repo, which you can find at: git://

The source code is broken down into merb-core, merb-more, and merb-plugins.

For more information on how to work with Git, see "So you want to contribute to Merb-core".

Once you have cloned the Git repos to your local system, you will then move into that directory and issue a "rake install" command to build the gem.
(Answer by ivey)

Q: Where are bugs / tickets being tracked now?

A: Along with the move to Github, bugs and ticket tracking has been moved from DevJaVu over to Lighthouse, specifically at

Answer of the week

Here is one little snippet of conversation that may provide the answer regardless of your specific problem:

Q: Can I do _____________?

hassox: I guess so
hassox: but I can't really help you on it...
grrt: :) I'll see how far I get
hassox: that's the spirit :)
grrt: it's great to just explore

Sometimes it's best to just try something out.

Audience Participation

Q: Merb-core has methods "render" and "display". What's the difference?

Leave your answer in the comments. (Hint)


  1. Correct the link to lighthouse, it's
    Keep up the good work with Merb! Can't wait for the 0.9 release. With more documentation it's going to be a real alternative to Rails.