I have a resource ''users''. the index page has a ''link_to'' tag I created on the line item level for a specific view. The link_to that is frustrating me in particular says: <%= link_to ''View'', :controller => ''users'', :action => ''view'' %> What''s happening is that it''s going to the Users controller and attempting to execute the ''show'' action (with ''view'' passed in as the id). But i am specifically requesting it to use the link_to to go to the ''view'' action. I''ve tried routing to another controller as well and that doesn''t change it at all. This is a rails 2.3.8 app if that matters in evaluating my question/ problem. Any help would be really appreciated. As an aside, I''ve even tried hi-jacking the ''show'' action by looking for a params id ''view'' and it fails before it even gets there (so assuming the route is smart enough to expect a non-string value). -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Phil On Sun, Feb 20, 2011 at 3:13 PM, T <bertke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a resource ''users''. the index page has a ''link_to'' tag I > created on the line item level for a specific view. The link_to that > is frustrating me in particular says: <%= link_to ''View'', :controller > => ''users'', :action => ''view'' %> > > What''s happening is that it''s going to the Users controller and > attempting to execute the ''show'' action (with ''view'' passed in as the > id). But i am specifically requesting it to use the link_to to go to > the ''view'' action. I''ve tried routing to another controller as well > and that doesn''t change it at all. >It will be a lot easier to just use the name of the route, eg, =link_to "View", view_user_path(user) (or whatever the name of the route is; you can always find it in the output of rake routes.> > This is a rails 2.3.8 app if that matters in evaluating my question/ > problem. Any help would be really appreciated. As an aside, I''ve > even tried hi-jacking the ''show'' action by looking for a params id > ''view'' and it fails before it even gets there (so assuming the route > is smart enough to expect a non-string value). > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
In this case the view I want to render is not one of the routes. I already have a show/edit/index view, I now need another one that is specialized and this may not be the last one I need. On Feb 20, 6:18 pm, Phil Crissman <phil.criss...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Phil > > On Sun, Feb 20, 2011 at 3:13 PM, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I have a resource ''users''. the index page has a ''link_to'' tag I > > created on the line item level for a specific view. The link_to that > > is frustrating me in particular says: <%= link_to ''View'', :controller > > => ''users'', :action => ''view'' %> > > > What''s happening is that it''s going to the Users controller and > > attempting to execute the ''show'' action (with ''view'' passed in as the > > id). But i am specifically requesting it to use the link_to to go to > > the ''view'' action. I''ve tried routing to another controller as well > > and that doesn''t change it at all. > > It will be a lot easier to just use the name of the route, eg, =link_to > "View", view_user_path(user) (or whatever the name of the route is; you can > always find it in the output of rake routes. > > > > > > > This is a rails 2.3.8 app if that matters in evaluating my question/ > > problem. Any help would be really appreciated. As an aside, I''ve > > even tried hi-jacking the ''show'' action by looking for a params id > > ''view'' and it fails before it even gets there (so assuming the route > > is smart enough to expect a non-string value). > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Feb 20, 2011 at 5:35 PM, T <bertke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In this case the view I want to render is not one of the routes. I > already have a show/edit/index view, I now need another one that is > specialized and this may not be the last one I need. >If you want to link_to the way you''re doing, it will need to be a route; you can add routes other than the standard RESTful set. See the routing guide in guides.rubyonrails.org. Yes, you _could_ one off ''render :template => "view" if params[:id] ="view" '', (or something like this, in the show action) but I really would discourage this sort of thing; your controller will become very hard to maintain. Phil> > On Feb 20, 6:18 pm, Phil Crissman <phil.criss...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Phil > > > > On Sun, Feb 20, 2011 at 3:13 PM, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have a resource ''users''. the index page has a ''link_to'' tag I > > > created on the line item level for a specific view. The link_to that > > > is frustrating me in particular says: <%= link_to ''View'', :controller > > > => ''users'', :action => ''view'' %> > > > > > What''s happening is that it''s going to the Users controller and > > > attempting to execute the ''show'' action (with ''view'' passed in as the > > > id). But i am specifically requesting it to use the link_to to go to > > > the ''view'' action. I''ve tried routing to another controller as well > > > and that doesn''t change it at all. > > > > It will be a lot easier to just use the name of the route, eg, =link_to > > "View", view_user_path(user) (or whatever the name of the route is; you > can > > always find it in the output of rake routes. > > > > > > > > > > > > > This is a rails 2.3.8 app if that matters in evaluating my question/ > > > problem. Any help would be really appreciated. As an aside, I''ve > > > even tried hi-jacking the ''show'' action by looking for a params id > > > ''view'' and it fails before it even gets there (so assuming the route > > > is smart enough to expect a non-string value). > > > > > -- > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Got it. Understand the points on not using the render in the show action. Thanks for the help, I appreciate it. On Feb 20, 6:43 pm, Phil Crissman <phil.criss...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Feb 20, 2011 at 5:35 PM, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > In this case the view I want to render is not one of the routes. I > > already have a show/edit/index view, I now need another one that is > > specialized and this may not be the last one I need. > > If you want to link_to the way you''re doing, it will need to be a route; you > can add routes other than the standard RESTful set. See the routing guide in > guides.rubyonrails.org. > > Yes, you _could_ one off ''render :template => "view" if params[:id] => "view" '', (or something like this, in the show action) but I really would > discourage this sort of thing; your controller will become very hard to > maintain. > > Phil > > > > > > > On Feb 20, 6:18 pm, Phil Crissman <phil.criss...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Phil > > > > On Sun, Feb 20, 2011 at 3:13 PM, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have a resource ''users''. the index page has a ''link_to'' tag I > > > > created on the line item level for a specific view. The link_to that > > > > is frustrating me in particular says: <%= link_to ''View'', :controller > > > > => ''users'', :action => ''view'' %> > > > > > What''s happening is that it''s going to the Users controller and > > > > attempting to execute the ''show'' action (with ''view'' passed in as the > > > > id). But i am specifically requesting it to use the link_to to go to > > > > the ''view'' action. I''ve tried routing to another controller as well > > > > and that doesn''t change it at all. > > > > It will be a lot easier to just use the name of the route, eg, =link_to > > > "View", view_user_path(user) (or whatever the name of the route is; you > > can > > > always find it in the output of rake routes. > > > > > This is a rails 2.3.8 app if that matters in evaluating my question/ > > > > problem. Any help would be really appreciated. As an aside, I''ve > > > > even tried hi-jacking the ''show'' action by looking for a params id > > > > ''view'' and it fails before it even gets there (so assuming the route > > > > is smart enough to expect a non-string value). > > > > > -- > > > > 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@googlegroups.com > > . > > > > To unsubscribe from this group, send email to > > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > For more options, visit this group at > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 20, 11:35 pm, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In this case the view I want to render is not one of the routes. I > already have a show/edit/index view, I now need another one that is > specialized and this may not be the last one I need. >Then add a route. ( check the :member option to resources) Fred> On Feb 20, 6:18 pm, Phil Crissman <phil.criss...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Phil > > > On Sun, Feb 20, 2011 at 3:13 PM, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have a resource ''users''. the index page has a ''link_to'' tag I > > > created on the line item level for a specific view. The link_to that > > > is frustrating me in particular says: <%= link_to ''View'', :controller > > > => ''users'', :action => ''view'' %> > > > > What''s happening is that it''s going to the Users controller and > > > attempting to execute the ''show'' action (with ''view'' passed in as the > > > id). But i am specifically requesting it to use the link_to to go to > > > the ''view'' action. I''ve tried routing to another controller as well > > > and that doesn''t change it at all. > > > It will be a lot easier to just use the name of the route, eg, =link_to > > "View", view_user_path(user) (or whatever the name of the route is; you can > > always find it in the output of rake routes. > > > > This is a rails 2.3.8 app if that matters in evaluating my question/ > > > problem. Any help would be really appreciated. As an aside, I''ve > > > even tried hi-jacking the ''show'' action by looking for a params id > > > ''view'' and it fails before it even gets there (so assuming the route > > > is smart enough to expect a non-string value). > > > > -- > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 20, 10:13 pm, T <ber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a resource ''users''. the index page has a ''link_to'' tag I > created on the line item level for a specific view. The link_to that > is frustrating me in particular says: <%= link_to ''View'', :controller > => ''users'', :action => ''view'' %>The best way would be to create named route however you can probably use url_for() for the job. You need to have globa routing turned on to make it working: link_to ''View'', url_for(:controller => ''users'', :action => ''view'') Robert Pankowecki -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.