Forum: Ruby on Rails playing with routes

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.
57014aac041f53d610b8609247d07385?d=identicon&s=25 Anthony Ward (ant284)
on 2009-05-18 15:22
Hi,

I'm currently playing with routes, and can't seem to find the solution
for this

i want to change the link of edit for a person
at the moment I have in route
map.resources :persons

and in the index of person's view folder i have
edit_person_path(person)

but it creates the link to
/persons/11/edit

i would like to change it like delete
/persons/11

I tried to do <link_to "edit",person , :method=>:get>
but it brings me to the show, which is the problem , I would like in
routes to say all :get for this persons goes to edit and not show.

thanks
D188e591eac11021329b8821a5f954c7?d=identicon&s=25 Ar Chron (railsdog)
on 2009-05-18 15:40
Run a

rake routes >routes.lst

then look at the routes.lst file. This wil show you all the routes that
mapping a resource generates for you by default.

What you're trying to do is alter the default behavior of restful
routing.  Your desired edit route is the default routing for show.  If
you override that, then you have to provide an alternative for the show
method.

If this is a pervasive desire that you simply *must* have, then I'd
suggest forgoing the restful routes in general, and dropping back to the
old routing method.

Get rid of the resource mapping, and "roll your own" routes. But the
nice thing about restful routes is the notion of programming by
convention
57014aac041f53d610b8609247d07385?d=identicon&s=25 Anthony Ward (ant284)
on 2009-05-18 15:46
Hi,

I wanted to keep the restful way, but see if was possible to just edit
show as I'm not using it for person. but if it is only possible by using
the old routing method, then I guess it is not what I want.

thank you


Ar Chron wrote:
> Run a
>
> rake routes >routes.lst
>
> then look at the routes.lst file. This wil show you all the routes that
> mapping a resource generates for you by default.
>
> What you're trying to do is alter the default behavior of restful
> routing.  Your desired edit route is the default routing for show.  If
> you override that, then you have to provide an alternative for the show
> method.
>
> If this is a pervasive desire that you simply *must* have, then I'd
> suggest forgoing the restful routes in general, and dropping back to the
> old routing method.
>
> Get rid of the resource mapping, and "roll your own" routes. But the
> nice thing about restful routes is the notion of programming by
> convention
This topic is locked and can not be replied to.