Posts Tagged router

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

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

, , , , , , ,