I would like to have some more friendly URLS ... I have some routes , with parameters I would like to rewrite but I don''t know if it''s possible : /programs?list=1 => /short_list /programs?list=2 => /medium_list /programs?list=3 => /long_list thanks for your feedback -- 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.
try to make it like this: match "programs/:id" => "Programs#your_action_name", :as => :list So in your controller ''Programs'' you are able to handle the request with the "id" which will be variable, and the path can be called by ''list_path''. The action you''ll call here will handle the request and you may then list the rows accordingly.. :) On Mon, Aug 22, 2011 at 4:31 PM, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote:> I would like to have some more friendly URLS ... > > I have some routes , with parameters I would like to rewrite but I > don''t know if it''s possible : > > > /programs?list=1 => /short_list > > /programs?list=2 => /medium_list > > /programs?list=3 => /long_list > > thanks for your feedback > > -- > 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 consider the environment before printing this email. Regards, Surya -- 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.
thanks , That''s better than what I did first, but is there any way to match to a specific name ( short_list, medium_list, long_list ) based upon the parameter 1, 2, 3 On Aug 22, 1:12 pm, Surya <raj.sury...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> try to make it like this: > > match "programs/:id" => "Programs#your_action_name", :as => :list > > So in your controller ''Programs'' you are able to handle the request with the > "id" which will be variable, and the path can be called by ''list_path''. The > action you''ll call here will handle the request and you may then list the > rows accordingly.. :) > > > > > > > > > > On Mon, Aug 22, 2011 at 4:31 PM, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > I would like to have some more friendly URLS ... > > > I have some routes , with parameters I would like to rewrite but I > > don''t know if it''s possible : > > > /programs?list=1 => /short_list > > > /programs?list=2 => /medium_list > > > /programs?list=3 => /long_list > > > thanks for your feedback > > > -- > > 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 consider the environment before printing this email. > > Regards, > Surya-- 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.
In my opinion you should let controller handle the size of your list, if it is ''programs/1'', ''programs/2'' or ''programs/3'' it will look for :controller => programs, :action => your_defined_action . So, in there in your action you just need to manipulate the params[:id] and according to it generate your data. For e.g. - if :id is 1 then generate your short_list, for 2 medium_list and for 3 long_list. Since, this all will be handle with in one action defined with in a controller it will be very compact and DRY, and can be viewed in a template. 3njoy :) On Mon, Aug 22, 2011 at 5:33 PM, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote:> thanks , That''s better than what I did first, > > but is there any way to match to a specific name ( short_list, > medium_list, long_list ) based upon the parameter 1, 2, 3 > > > > > On Aug 22, 1:12 pm, Surya <raj.sury...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > try to make it like this: > > > > match "programs/:id" => "Programs#your_action_name", :as => :list > > > > So in your controller ''Programs'' you are able to handle the request with > the > > "id" which will be variable, and the path can be called by ''list_path''. > The > > action you''ll call here will handle the request and you may then list the > > rows accordingly.. :) > > > > > > > > > > > > > > > > > > > > On Mon, Aug 22, 2011 at 4:31 PM, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > I would like to have some more friendly URLS ... > > > > > I have some routes , with parameters I would like to rewrite but I > > > don''t know if it''s possible : > > > > > /programs?list=1 => /short_list > > > > > /programs?list=2 => /medium_list > > > > > /programs?list=3 => /long_list > > > > > thanks for your feedback > > > > > -- > > > 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. > > > > -- > > > > Please consider the environment before printing this email. > > > > Regards, > > Surya > > -- > 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 consider the environment before printing this email. Regards, Surya -- 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 Aug 22, 2011, at 8:13 AM, Surya wrote:> In my opinion you should let controller handle the size of your > list, if it is ''programs/1'', ''programs/2'' or ''programs/3'' it will > look for :controller => programs, :action => your_defined_action . > So, in there in your action you just need to manipulate the > params[:id] and according to it generate your data. For e.g. - > if :id is 1 then generate your short_list, for 2 medium_list and for > 3 long_list. Since, this all will be handle with in one action > defined with in a controller it will be very compact and DRY, and > can be viewed in a template. 3njoy :) > > On Mon, Aug 22, 2011 at 5:33 PM, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote: > thanks , That''s better than what I did first, > > but is there any way to match to a specific name ( short_list, > medium_list, long_list ) based upon the parameter 1, 2, 3I think you''re asking about this: match ''/short_list'' => "Programs#list", :list_id => 1, :as => ''short_list'' match ''/medium_list'' => "Programs#list", :list_id => 2, :as => ''medium_list'' match ''/long_list'' => "Programs#list", :list_id => 3, :as => ''long_list'' The URL has the word and the controller gets a number as the parameter. -Rob Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.com/> > > > > On Aug 22, 1:12 pm, Surya <raj.sury...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > try to make it like this: > > > > match "programs/:id" => "Programs#your_action_name", :as => :list > > > > So in your controller ''Programs'' you are able to handle the > request with the > > "id" which will be variable, and the path can be called by > ''list_path''. The > > action you''ll call here will handle the request and you may then > list the > > rows accordingly.. :) > > > > > > > > > > > > > > > > > > > > On Mon, Aug 22, 2011 at 4:31 PM, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > I would like to have some more friendly URLS ... > > > > > I have some routes , with parameters I would like to rewrite but I > > > don''t know if it''s possible : > > > > > /programs?list=1 => /short_list > > > > > /programs?list=2 => /medium_list > > > > > /programs?list=3 => /long_list > > > > > thanks for your feedback > > > > > -- > > > 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. > > > > -- > > > > Please consider the environment before printing this email. > > > > Regards, > > Surya > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . > > > > > -- > Please consider the environment before printing this email. > > > Regards, > Surya > > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > .Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org +1 513-295-4739 Skype: rob.biedenharn -- 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.