rgreen
January 3, 2010, 4:18am
1
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 [email protected] .
To unsubscribe from this group, send email to
[email protected] .
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en .
rgreen
January 3, 2010, 7:08am
2
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 [email protected] 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 [email protected] .
To unsubscribe from this group, send email to
[email protected] .
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en .
rgreen
January 3, 2010, 11:48am
3
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 [email protected]
For more options, visit this group at
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 [email protected] .
To unsubscribe from this group, send email to
[email protected] .
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en .
rgreen
January 3, 2010, 8:07pm
4
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
[email protected]
rgreen
January 3, 2010, 7:54pm
5
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. [email protected] wrote:
2010/1/3 Rong [email protected]
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected] .
To unsubscribe from this group, send email to
[email protected] <rubyonrails-talk%2Bunsubscrib [email protected] >
.
For more options, visit this group at
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 [email protected] .
To unsubscribe from this group, send email to
[email protected] .
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en .
rgreen
January 5, 2010, 2:25am
6
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
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
[email protected]
rgreen
January 4, 2010, 5:06am
7
This is not a real app. so stuff your perversion and top posting.
I got this from RailsCasts
On Jan 3, 1:07 pm, Marnen Laibow-Koser [email protected] 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 [email protected] .
To unsubscribe from this group, send email to
[email protected] .
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en .
rgreen
January 5, 2010, 5:14am
8
I understand.
My apologies for my rudeness.
On Jan 4, 7:25 pm, Marnen Laibow-Koser [email protected] wrote:
you’re doing – you don’t want to make every static page a custom REST
action.
Best,
Marnen Laibow-Koserhttp://www.marnen.org
[email protected]
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 [email protected] .
To unsubscribe from this group, send email to
[email protected] .
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en .