Call named routes in CakePHP as the same way in Ruby on Rails

Posted by Lucas Renan on Stack Overflow See other posts from Stack Overflow or by Lucas Renan
Published on 2010-03-27T03:00:11Z Indexed on 2010/03/27 3:03 UTC
Read the original article Hit count: 607

How can I call a route (in the view) in CakePHP as the same way in Rails?

Ruby on Rails

routes.rb

map.my_route '/my-route', :controller => 'my_controller', :action => 'index'

view

link_to 'My Route Name', my_route_path

CakePHP

routes.php

Router::connect('/my-route', array('controller' => 'my_controller', 'action' => 'index'));

view

$html->link('My Route Name', '/my-route');

But I think the Rails way is better, because I can make changes in the "url" and I don't need changes the code of the views.

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about ruby-on-rails