Forum: Ruby on Rails routes.rb problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C42c706fab23da0b6d3cd2cfbb8db27d?d=identicon&s=25 Salil Gaikwad (salil)
on 2009-03-06 15:39
I am having problem with routes.rb

I want to access same page using two different url's for that i had done
following in routes.rb
1]   map.connect 'projects/:project_id/issues/:action', :controller =>
'issues'
so when my url is
http://localhost:3000/projects/xyz/issues/new

i access the new.rhtml page of a issue controller

what i want that when i write simply

http://localhost:3000/issues/new it should render me to the action new
of a issues controller.

i try something like this in routes.rb

map.connect 'issues/:action', :controller => 'issues', :action=>'new'

and then restart the server but it doesn't works....
247cd3d37084a3d6794076207bd9fbd7?d=identicon&s=25 Bob Martens (Guest)
on 2009-03-06 18:49
(Received via mailing list)
Why not just map.resources :issues and go from there? That is a
RESTful resource, right?

On Mar 6, 8:39 am, Salil Gaikwad <rails-mailing-l...@andreas-s.net>
5f3d52658aafcf0aabe76a5147e8909f?d=identicon&s=25 tomrossi7 (Guest)
on 2009-03-06 19:22
(Received via mailing list)
Where does the application take you when you go to /issues/new?  You
can always comment out other routes until you find the one that is
causing the conflict...
--Tom

On Mar 6, 9:39 am, Salil Gaikwad <rails-mailing-l...@andreas-s.net>
247cd3d37084a3d6794076207bd9fbd7?d=identicon&s=25 Bob Martens (Guest)
on 2009-03-06 21:10
(Received via mailing list)
Can you show us your rake routes to see what you have defined?
8d295740bdc6fecc406cff2e8b895f48?d=identicon&s=25 sahil (Guest)
on 2009-03-07 08:33
(Received via mailing list)
On Mar 6, 7:39 pm, Salil Gaikwad <rails-mailing-l...@andreas-s.net>
wrote:
> I am having problem with routes.rb
>
> I want to access same page using two different url's for that i had done
> following in routes.rb
> 1]   map.connect 'projects/:project_id/issues/:action', :controller =>
> 'issues'

you should always use.. RESTful routes.. instead of above try this:

map.resources :projects, :has_many => :issues
20ee0d23c969c7740d3c936a4675bb23?d=identicon&s=25 Sarah Allen (ultrasaurus)
on 2009-03-08 04:53
Salil Gaikwad wrote:
> i try something like this in routes.rb
>
> map.connect 'issues/:action', :controller => 'issues', :action=>'new'
>
> and then restart the server but it doesn't works....

Try this in irb
>> rts = ActionController::Routing::Routes
>> rts.recognize_path("issues/new")

and it'll return the route that maps to it

This and other cool tips in a nice tutorial by Daryn Holmes:
http://darynholmes.wordpress.com/2008/03/15/beginn...

Sarah
This topic is locked and can not be replied to.