Archive for September, 2008

problems with urls in Merb HEAD?

I actually run into a small problem when updated an older Merb app. Here was how my router looked like:

Merb::Router.prepare do |r|
  r.resources :channels do |channels|
    channels.resources :shows do |shows|
      shows.resources :episodes

But after updating to the latest version of Merb, I got links looking like:


The first thing to do is to read Carl’s wiki about the latest Router changes.

Carl explains that things got cleaned up in the router code and my routes should now look like:

Merb::Router.prepare do |r|
  r.resources :channels do
    resources :shows do |shows|
      resources :episodes

However that won’t be enough.. You see my url used to look like that:

url(:channel_shows, :channel_id =&gt; channel)

Now I can simplify it to:

url(:channel_shows, channel)

That still won’t fix the problem, since the real problem comes from the fact that I was on Merb HEAD but not DataMapper HEAD. Updating DM clears things up. That’s the price to pay to be on HEAD ;)

FYI the problem comes from the fact that DM doesn’t add a to_params method to its objects. Rails users might recognize that method used to convert an object into a string to create a route, something not really ORM agnostic and frowned upon by the DM/Merb teams.

Merb lets you specify the param to use for your routes using the identify method. Read Carl’s wiki page for more cool stuff and see how to create some cool stuff like url slugs etc..

Note that even if you are using ActiveRecord, you’ll need to update merb_activerecord as the new identify rules were updated in the ORM plugins.

, ,

No Comments

Write your own custom DataMapper adapter

If you read this blog, you probably know that Merb‘s best ORM friend is DataMapper.

compounds in basil oil have potent antioxidant and is used for supplementary treatment of stress

compounds in basil oil have potent antioxidant and is used for supplementary treatment of stress

Merb works very well with ActiveRecord and Sequel but most of the Merbivores get excited about DataMapper.

DataMapper has a lot of cool stuff going for it. I’m planning on writingi few articles about what I particularily like with DM and some of the misconceptions.

I’m going to give a talk about DataMapper during MerbCamp and something I want to cover is the fact that you can write DM adapters for virtually anything. From an adapter for couchdb (available in dm-more) to an adapter for SalesForce API. That’s the kind of stuff that gets me excited, a bit like what Ambition does but built-in in DM.

So, I decided to take some advise from Yehuda and dkubb and wrote my own adapter for Google Video. I had just finished a gem to retrieve google videos for a given google user and thought it would be a perfect exercise to mix a http-scraper with a DM adapter.

Read the rest of this entry »

, , ,


quick preview of the work done pre 1.0

Yesterday I spyed on wycats aka Yehuda Katz while he’s working on cleaning things up for 1.0 which will be released during MerbCamp Oct 11-12.

Here is the screenshot of how you would see ugly backtraces originating from Merb’s core:

old backtraces

old backtraces

Note: Did you notice that wycats is using Ruby Enterprise Edition? Merb 0.9.8 has been modified to really take advantage of REE!

That’s a lot of noise just to tell you that you used an invalid argument

Well, part of the prep work for Merb 1.0 is to clean up this things to make development work easier and nicer. Here is how the same error will look like in 1.0

new backtraces

new backtraces

As you can see, it’s way more elegant and less confusing. You can still see the full trace by using the –verbose argument.


1 Comment

merbist scrapbook (sept-25)

Fennel, one of the primary ingredients of absinthe helps developers creativity.

Fennel, one of the primary ingredients of absinthe helps developers' creativity.

  • Good news regarding Merb slices: the new router allows you to mount a slice directly as: /the-slice-action (previously it had to be /the-slice/something)
  • On IRC, Nagash came up with an interesing snippet allowing you to easily serve static views (like Django’s generic views) (Merb::Template.template_for is PRIVATE so use it at your own risk) The Core team is investigating simpler/cleaner ways of achieving the same result and a built-in solution should be available in Merb 1.1
  • Merb 0.9.8 will be optimized for Ruby Enterprise Edition and will be supporting a new way of handling gems without wasting so much memory. (more news coming up soon)
  • Merb 0.9.8 has a new efficient way of dealing with clusters (more news coming soon)
  • Merb’s new caching system will make it to 1.0
  • Merb is going into a feature freeze and the team will focus solely on bug fixes and making the Merb experience more pleasant.
  • A turn key deployment solution is planned for Merb 1.x (deployment recipes plugin)
  • DataMapper benchmarks show it’s now way faster than ActiveRecord (on average) Benchmark scripts available in the dm-core repo.

, , , ,

No Comments

News from the front line – Sept 24 2008

Dear Merbivores/Merbists/Merbians,

It’s hard to believe that in less that 20 days, Merb 1.0 will be released! We are all really happy to to be almost there but we have to be honest and admit that we are also under pressure.

We are all dreaming of a post 1.0 world but in the meantime we have to focus on last minutes bugs and optimization.

During the last week or so, we made a lot of progress, the API is now “almost” frozen and General Katz is focusing on making sure everything will be fine for D Day.

That reminds me that Katz showed me something amazing yesterday! I shouldn’t really talk about it but I’m sure it will stay between us. He was been working on optimizing the general memory consumption and my testing app (real app) went from 120MB of Private Memory used, to 70MB (using 4 processes). I can’t wait to use that on the field. I also hope my old Rails comrades will realize that running ~100Mb processes (x4) really isn’t efficient and event dangerous for the free Ruby world!

I also heard rumors that the higher officers are now using a new strategic tool called which should help us streamline the process. We are still using LightHouse to track bugs and patches though. I’m not sure if this new “agile” tool will help, but I thought the approach is pretty interesting. What do you think?

You probably also saw my early report on bundling Merb apps, I’m quite happy about the process. Do you think you will deploy bundled/frozen apps or just use the system-wide gems?

Finally I hear a lot of talk about the new Router that’s available on Edge/HEAD. Officer Lerch wrote a nice wiki article covering the changes, you might want to read it.

Ohh before I forget, some courageous privates went to HEAD and use the 3rd party plugin called merb-auth. What they don’t know is that they need to change their routes to use the slices with the new router. (the new router requires no block variable) Also, if they look at the merb-auth branches they will notice a new mauth branch which is the new version of merb-auth, even better, more flexible than the previous version.

I hope everything is well for you, say Hi! to our friends for me.

- Merbist

, , , , , , ,


Deploying a bundled merb app (merb 0.9.7+)

Since Merb 0.9.7 the Merb team decided to change the way you can bundle an app. Until 0.9.7 you would use the merb-freezer plugin which was supporting git submodules and gems. The only problem was that you still had to install merb-freezer on your server and it had to stay in sync with your app… kinda lame :(


Ginger roots, great for deployment issues

Instead, after a lot of discussions, we decided to add this feature to merb-core and let you bundle all your dependencies in a bundled gem folder. No more support for git submodules as they are hard to keep track of and don’t handle dependencies very well (not at all).

The new freezing strategy is very well described in this merbunity article. However it doesn’t really explain how to deploy a bundled app.

So let’s imagine for a second that we bundle our app, generated the scripts needed to start merb/rake etc…

Read the rest of this entry »

, , , , ,