# Restful routes

**URL:** <https://www.ruby-forum.com/t/restful-routes/180990>\
**Category:** Rails\
**Created:** [January 3, 2010, 4:18am UTC](https://www.ruby-forum.com/t/restful-routes/180990 "2010-01-03T04:18:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 3, 2010, 4:18am UTC](https://www.ruby-forum.com/t/restful-routes/180990/1 "2010-01-03T04:18:56Z")

</div>

If I created a route like this  
map.about ‘/about’, :controller =\> ‘pages’, :action =\> 'about

And then added this to a different page  
\<%= link\_to “About”, about\_url %\>

And decided to change my route to  
map.resources :about

the link to no longer works.

What am I doing wrong?

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 3, 2010, 7:08am UTC](https://www.ruby-forum.com/t/restful-routes/180990/2 "2010-01-03T07:08:05Z")

</div>

An “about us” page is not a candidate for a rest resource. You had it  
fine before.

If you turned your pages controller into a rest resource and moved the  
“about” page into the resulting cms, then you might create a helper  
method “about\_url” that generates the newly correct url.

If you wanted users to be able to create many “abouts”, edit and  
destroy them, then you would create an “abouts\_controller”. The index  
action would give a list of abouts (abouts\_url would link to it). If  
you want to view an individual “about” then about\_url(@about). To edit  
it, edit\_about\_url(about). To update it, the form\_for(@about) will  
take care of the put method. Likewise, link\_to “delete about”,  
about\_url(about), :method =\> :delete will remove it. To create a new  
one, new\_about\_url will get you there.

On Jan 2, 10:17 pm, Rong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What am I doing wrong?

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 3, 2010, 11:48am UTC](https://www.ruby-forum.com/t/restful-routes/180990/3 "2010-01-03T11:48:26Z")

</div>

And how about your Page Controller, did you change it to About  
Controller?

In your first implementation you’ve used Pages Controller to create your  
About page. If you didn’t change it to and About Controller you can to  
do  
something loke that:

map.resources :pages, :member =\> { :about =\> :get }

[]'s

2010/1/3 Rong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Thais C.  
… nem todo mundo Ã© igual, as experiÃªncias da vida definem atitudes

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 3, 2010, 8:07pm UTC](https://www.ruby-forum.com/t/restful-routes/180990/4 "2010-01-03T20:07:30Z")

</div>

Ron G. wrote:

> The correct answer is:
> 
> map.resources :pages, :collection =\> {:home =\> :get, :about  
> =\> :get, :contact =\> :get }
> 
> and then the link\_to becomes:
> 
> \<%= link\_to ‘About’, about\_pages\_path%\>

This is a bit of a perversion of map.resources. You probably want to  
just consider this :controller/:action (which the default routes already  
provide).

[Please don’t top-post.]

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 3, 2010, 7:54pm UTC](https://www.ruby-forum.com/t/restful-routes/180990/5 "2010-01-03T19:54:51Z")

</div>

The correct answer is:

map.resources :pages, :collection =\> {:home =\> :get, :about  
=\> :get, :contact =\> :get }

and then the link\_to becomes:

\<%= link\_to ‘About’, about\_pages\_path%\>

On Jan 2, 9:41 pm, Thais C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 2010/1/3 Rong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> > “Ruby on Rails: Talk” group.  
> > To post to this group, send email to removed\_email\_address@domain.invalid.  
> > To unsubscribe from this group, send email to  
> > removed\_email\_address@domain.invalid\<rubyonrails-talk%2Bunsubscrib removed\_email\_address@domain.invalid\>  
> > .  
> > For more options, visit this group at  
> > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
> 
> –  
> Thais C.  
> … nem todo mundo é igual, as experiências da vida definem atitudes

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 5, 2010, 2:25am UTC](https://www.ruby-forum.com/t/restful-routes/180990/6 "2010-01-05T02:25:33Z")

</div>

Ron G. wrote:

> This is not a real app. so stuff your perversion and top posting.

Be polite if you want help. And if it’s not a real app, then why waste  
your time on it? Presumably to learn good practice, right?

> I got this from RailsCasts  
> [#35 Custom REST Actions - RailsCasts](http://railscasts.com/episodes/35-custom-rest-actions)

Yes, it will work. My point was that it’s conceptually wrong for what  
you’re doing – you don’t want to make every static page a custom REST  
action.

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 4, 2010, 5:06am UTC](https://www.ruby-forum.com/t/restful-routes/180990/7 "2010-01-04T05:06:51Z")

</div>

This is not a real app. so stuff your perversion and top posting.  
I got this from RailsCasts

> **[\#35 Custom REST Actions - RailsCasts](http://railscasts.com/episodes/35-custom-rest-actions)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

On Jan 3, 1:07 pm, Marnen Laibow-Koser [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This is a bit of a perversion of map.resources. You probably want to  
> Posted viahttp://www.ruby-forum.com/.  
> –

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![rgreen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f04885/32.png) [@rgreen](https://www.ruby-forum.com/u/rgreen)\
**Post date:** [January 5, 2010, 5:14am UTC](https://www.ruby-forum.com/t/restful-routes/180990/8 "2010-01-05T05:14:58Z")

</div>

I understand.  
My apologies for my rudeness.

On Jan 4, 7:25 pm, Marnen Laibow-Koser [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> you’re doing – you don’t want to make every static page a custom REST  
> action.
> 
> ## Best,
> 
> ## Marnen Laibow-Koserhttp://www.marnen.org removed\_email\_address@domain.invalid
> 
> Posted viahttp://www.ruby-forum.com/.

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
