Hi there Is it possible to pass a parameter automatically to every rails generated link? for example: I have the parameter site_id which is passed via url (www.example.com/:site_id/:controller/:action/:id) is it possible to automatically pass the :site_id to all links/paths like f.i. "articles_path", "article_path(@article)" or is the only way to do this by passing the parameter in addition: "articles_path(:site_id=>params[:site_id])" or "article_path(@article, :site_id=>params[:site_id])". Thanks for your answers Regards sigma -- 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.
On 7 July 2010 17:21, sigma <christoph.thommen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there > > Is it possible to pass a parameter automatically to every rails > generated link? > > for example: > > I have the parameter site_id which is passed via url > (www.example.com/:site_id/:controller/:action/:id) > > is it possible to automatically pass the :site_id to all links/paths > like f.i. "articles_path", "article_path(@article)" or is the only way > to do this by passing the parameter in addition: > "articles_path(:site_id=>params[:site_id])" or > "article_path(@article, :site_id=>params[:site_id])".I don''t know the answer but if you are simply passing it backwards and forwards in order to persist it then you might be better off using the session. (session[:site_id] = ...) Colin -- 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.
Hi thanks, but this is not really what i''m looking for. I looking for a solution to (re-)pass a given parameter to all rails generated links. sigma On 7 Jul., 19:03, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 7 July 2010 17:21, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi there > > > Is it possible to pass a parameter automatically to every rails > > generated link? > > > for example: > > > I have the parameter site_id which is passed via url > > (www.example.com/:site_id/:controller/:action/:id) > > > is it possible to automatically pass the :site_id to all links/paths > > like f.i. "articles_path", "article_path(@article)" or is the only way > > to do this by passing the parameter in addition: > > "articles_path(:site_id=>params[:site_id])" or > > "article_path(@article, :site_id=>params[:site_id])". > > I don''t know the answer but if you are simply passing it backwards and > forwards in order to persist it then you might be better off using the > session. (session[:site_id] = ...) > > Colin-- 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.
[Please quote when replying.] Christoph Thommen wrote:> Hi > > thanks, but this is not really what i''m looking for. > I looking for a solution to (re-)pass a given parameter to all rails > generated links.And why won''t a session variable do the trick? It seems to me that Colin is right. You *could* override some of the UrlWriter functions, but you really, really want a session variable, unless there''s something I don''t understand here.> > sigmaBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/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.
Hi Ok, sessions seems to be right, but not what I''m looking for :-) This parameter is not static, it is dynamic. the whole thing is for a CMS where the ":site-id" tells where the user stands in the navigation and what''s the site title,... So it would be much better to pass this by url. sigma On 7 Jul., 22:44, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> [Please quote when replying.] > > Christoph Thommen wrote: > > Hi > > > thanks, but this is not really what i''m looking for. > > I looking for a solution to (re-)pass a given parameter to all rails > > generated links. > > And why won''t a session variable do the trick? It seems to me that > Colin is right. > > You *could* override some of the UrlWriter functions, but you really, > really want a session variable, unless there''s something I don''t > understand here. > > > > > sigma > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > 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 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 8 July 2010 06:16, sigma <christoph.thommen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > > Ok, sessions seems to be right, but not what I''m looking for :-) > > This parameter is not static, it is dynamic. the whole thing is for a > CMS where the ":site-id" tells where the user stands in the navigation > and what''s the site title,... So it would be much better to pass this > by url.I would suggest that if you are using it for context information (where the user is now) then the session is exactly the right place to put it. Just update the session each time the value changes. A URL is for indicating what to do next, not passing where you are at the moment. By the way it is generally preferred not to top post on this list, it is easier to follow a thread if you insert your comments inline in the previous message. Thanks. Colin> > sigma > > On 7 Jul., 22:44, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> [Please quote when replying.] >> >> Christoph Thommen wrote: >> > Hi >> >> > thanks, but this is not really what i''m looking for. >> > I looking for a solution to (re-)pass a given parameter to all rails >> > generated links. >> >> And why won''t a session variable do the trick? It seems to me that >> Colin is right. >> >> You *could* override some of the UrlWriter functions, but you really, >> really want a session variable, unless there''s something I don''t >> understand here. >> >> >> >> > sigma >> >> Best, >> -- >> Marnen Laibow-Koserhttp://www.marnen.org >> mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org >> -- >> 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 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. > >-- 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 Jul 8, 9:43 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 July 2010 06:16, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi > > > Ok, sessions seems to be right, but not what I''m looking for :-) > > > This parameter is not static, it is dynamic. the whole thing is for a > > CMS where the ":site-id" tells where the user stands in the navigation > > and what''s the site title,... So it would be much better to pass this > > by url. > > I would suggest that if you are using it for context information > (where the user is now) then the session is exactly the right place to > put it. Just update the session each time the value changes. A URL > is for indicating what to do next, not passing where you are at the > moment. > > By the way it is generally preferred not to top post on this list, it > is easier to follow a thread if you insert your comments inline in the > previous message. Thanks. > > Colin > >Hi I think you didn''t understand what I mean... Every Controller is something like a module in this cms. so you can put such a module on different places on the website. so you have a navigation, which points to a module (contoller) and a certain place, where this module is placed within the navigation. In this case the URL should also contain the site-id (navigation-id) in order to find out which content of the module is part of this navigation item. So you can''t pass this via session. For example: we habe a news-module which is placed on the home page (site_id = 1) and under "about > blog" (site_id = 99). so the url would look like this: www.example.com/1/news for the home page and www.example.com/99/news for the "about > blog" page. and this you can''t pass by session. sigma> > > sigma > > > On 7 Jul., 22:44, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> [Please quote when replying.] > > >> Christoph Thommen wrote: > >> > Hi > > >> > thanks, but this is not really what i''m looking for. > >> > I looking for a solution to (re-)pass a given parameter to all rails > >> > generated links. > > >> And why won''t a session variable do the trick? It seems to me that > >> Colin is right. > > >> You *could* override some of the UrlWriter functions, but you really, > >> really want a session variable, unless there''s something I don''t > >> understand here. > > >> > sigma > > >> Best, > >> -- > >> Marnen Laibow-Koserhttp://www.marnen.org > >> mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > >> -- > >> 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 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 athttp://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 Jul 7, 5:21 pm, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there > > Is it possible to pass a parameter automatically to every rails > generated link? >ActionController::default_url_options ? Fred -- 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 Jul 8, 11:48 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 7, 5:21 pm, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi there > > > Is it possible to pass a parameter automatically to every rails > > generated link? > > ActionController::default_url_options ? > > FredHi Fred This is exaclty what I''m looking for! Thank you -- 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.