e.g. index.rhtml has: <%= link_to ''nextpage'' :action=>''show'' %> when it is clicked, it will take you to nextpage_controller, then execute ''show'', then stay in nextpage.rhtml. If that is the case, action ''show'' has to exist, even it is an empty action, in order to take you from index.rhtml to nextpage.rhtml, right? -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Gary Liang wrote:> e.g. > > index.rhtml has: > <%= link_to ''nextpage'' :action=>''show'' %> > when it is clicked, it will take you to nextpage_controller, then > execute ''show'', then stay in nextpage.rhtml. > > If that is the case, action ''show'' has to exist, even it is an empty > action, in order to take you from index.rhtml to nextpage.rhtml, right?I make this question simplier. Does it mean nextpage.rhtml must has a controller & action ''show'', in order to transfer to from index.rhtml (index.rhtml has <%= link_to ''nextpage'' :action=>''show'' %> ?) to nextpage.rhtml. -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Jan-16 03:39 UTC
Re: Quick questions about link_to
Hi -- On Tue, 16 Jan 2007, Gary Liang wrote:> > Gary Liang wrote: >> e.g. >> >> index.rhtml has: >> <%= link_to ''nextpage'' :action=>''show'' %> >> when it is clicked, it will take you to nextpage_controller, then >> execute ''show'', then stay in nextpage.rhtml. >> >> If that is the case, action ''show'' has to exist, even it is an empty >> action, in order to take you from index.rhtml to nextpage.rhtml, right? > > I make this question simplier. > > Does it mean nextpage.rhtml must has a controller & action ''show'', in order > to transfer to from index.rhtml (index.rhtml has <%= link_to ''nextpage'' > :action=>''show'' %> ?) to nextpage.rhtml.You can have no show action, in which case it will be treated as just a request to render show.rhtml. I usually like to put: def show end in my controller anyway, just to denote the fact that I''m expecting requests to it. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Does it mean nextpage.rhtml must has a controller & action ''show'', in > order to transfer to from index.rhtml (index.rhtml has <%= link_to > ''nextpage'' :action=>''show'' %> ?) to nextpage.rhtml.This link won''t change controllers because you haven''t specified a ":controller" option. This link will simply point to the "show" action in the same controller as index.rhtml. That means that rails will try to render a view named show.rhtml in the same directory as index.rhtml. If you want to go to the nextpage.rhtml view (nextpage action) in the current controller, then you need to use a link like this: <%= link_to ''Next Page'' :action=>''nextpage'' %> Note that the first string is what the user sees in the link. If you want to go to the show.rhtml view in the nextpage controller (for example), then you need a link like this: <%= link_to ''Next Page'' :controller => ''nextpage'', :action=>''show'' %> -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---