On May 30, 2007, at 10:00 PM, Zack Chandler wrote:

> I put together a sample app to help people learn Merb:
> http://svn.depixelate.com/applications/invoice_tracker/
>
> I also blogged about it here:
> http://depixelate.com/2007/5/31/taking-merb-for-a-spin
>
> --
> Zack Chandler
> http://depixelate.com

Zack-

        That's kick ass, thanks for doing that! Dave Goodlad did some really  
nice work on adding a route generator to merb. I spent some time and  
integrated it into merb trunk.

        So if you drop into merb -i console you have a show_routes method  
available and also a url method. The url method is also available in  
your controllers and views. Note that there is a slight change to the  
router definition in router.rb due to the routing refactor.

# router.rb
# note you need top use Merb::Router instead of Merb::RouteMatcher now:
Merb::Router.prepare do |r|
   r.resources :posts do |post|
     post.resources :comments
   end
   r.default_routes
end


$ merb -i
merb init called
irb(main):001:0> show_routes
[:edit_comment, "/posts/:post_id/comments/:id/edit"]
[:new_post, "/posts/new"]
[:posts, "/posts"]
[:custom_new_post, "/posts/new/:action"]
[:edit_post, "/posts/:id/edit"]
[:comment, "/posts/:post_id/comments/:id"]
[:post, "/posts/:id"]
[:new_comment, "/posts/:post_id/comments/new"]
[:custom_new_comment, "/posts/:post_id/comments/new/:action"]
[:comments, "/posts/:post_id/comments"]
=> nil
irb(main):002:0> url :edit_comment, :post_id => 42, :id => 24
=> "/posts/42/comments/24/edit"
irb(main):003:0> url :posts
=> "/posts"


        Thanks for making your sample app available, I'm sure it will help  
people get up to speed in merbland.

Cheers-
-- Ezra Zygmuntowicz 
-- Lead Rails Evangelist
-- [EMAIL PROTECTED]
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)


_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

Reply via email to