Blogger.create { :name =>'Matt Aimonetti',
:location => 'San Diego, Ca',
:email => mattaimonetti AT gmail.com,
:linkedin => Matt's Linkedin page,
:recommend_me => HERE,
:contractor => true}

Merb tips I

Written by matt on April 4th, 2008

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

  1. In the init.rb file, uncomment and rename c[:session_id_key] (in the Merb::Config.use block)

  2. In the same block, add c[:log_level] = :debug to set a log level

  3. By default, Merb logs to STDOUT, to log to a file, in the config block add c[:log_file] = Merb.log_path + '/development.log' (note that you need to create the file yourself, Merb won't do that)

  4. to save your gems locally, do: sudo gem install gem_name -i gems

  5. need basic HTTP auth? it's now available in core

  6. don't forget to require any plugins, extra gems you need (such as merb_helpers or merb-assets)

  7. don't forget to select your ORM before using the generator( so your generated goodies will be adapted to your ORM)

  8. routes are easy to use. In the console (merb -i) type merb.show_routes to see all your named routes

  9. if you want to use linkto, install merbassets

  10. 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
2
3
4

  url(:channel_shows, :channel_id => channel)

  link_to h(channel.description), url(:channel, :id => channel)

That's it for today :)

In the meantime, check this Merb presentation by Ezra and this DataMapper presentation by Wycats



Comments

  • Dr Nic on 05 Apr 16:04

    If you add MERBORM and MERBTEST_SUITE to your environment (globably or when you run merb-gen) then you'll get the ORM + preferred test suite automatically enabled (either on edge merb or 0.9.2, not sure)

    $ env | grep MERB MERBTESTSUITE=spec MERB_ORM=datamapper

  • Justin on 07 Apr 10:15

    So do you have to set the log path? If not, what is it set to?

  • Matt Aimonetti on 07 Apr 10:47

    @justin if you don't set the path and don't create the log file the logs will just go to your terminal. if you set the log path but don't create the log file, nothing will happen.

    -Matt

  • Jonas Nicklas on 07 Apr 13:58

    HTTP Basic Authentication is now avilable in merb-core, so there is no need for the plugin anymore.

    /Jonas

  • Guillaume Maury on 19 Apr 07:03

    in merb 0,92, linkto is provided in merb-assets not merbhelpers

Post a comment