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 end end end
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 end end end
However that won’t be enough.. You see my url used to look like that:
url(:channel_shows, :channel_id => channel)
Now I can simplify it to:
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.