Merb Tips 1
* this content is now outdated and only applied to Merb 0.9*
I’m working on a post reporting a recent benchmark I did comparing Rails vs Merb performances for a client’s app.
In the meantime, here are few tricks you might need when using Merb 0.9x
In the init.rb file, uncomment and rename _c[:session_idkey] (in the Merb::Config.use block)
In the same block, add _c[:loglevel] = :debug to set a log level
By default, Merb logs to STDOUT, to log to a file, in the config block add _c[:log_file] = Merb.logpath + ‘/development.log’ (note that you need to create the file yourself, Merb won’t do that)
to save your gems locally, do: _sudo gem install gemname -i gems
need basic HTTP auth? it’s now available in core
don’t forget to require any plugins, extra gems you need (such as _merbhelpers or merb-assets)
don’t forget to select your ORM before using the generator( so your generated goodies will be adapted to your ORM)
routes are easy to use. In the console (merb -i) type _merb.showroutes to see all your named routes
if you want to use link_to, install merb_assets
nested routes example:
1 2 3 4 5 6
r.resources :channels do |channels| channels.resources :shows do |shows| shows.resources :episodes end end
usage:
1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt>
<tt>
</tt> url(<span class="sy">:channel_shows</span>, <span class="sy">:channel_id</span> => channel)<tt>
</tt><tt>
</tt> link_to h(channel.description), url(<span class="sy">:channel</span>, <span class="sy">:id</span> => channel)<tt>
</tt>
That’s it for today :)
In the meantime, check this Merb presentation by Ezra and this DataMapper presentation by Wycats