Hello is there any way to pass paramters in a more proper way than I do currently? Since it''s the easiest way I''m just passing them as GET parameters at the moment for example: http://localhost:3000/actions/980190963/add_date?t=2010-02-23 http://localhost:3000/actions/new?at=678542324&t=851829735&tt=Type1 I really don''t like that way of passing parameters and doesn''t look very rails-like. So solution I can think of so far is to turn all of these links into forms with hidden tags but I don''t really like that either even though I think it''s better than now. Anyone knowing a better solution to this? Thanks! -- 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.
On 22 February 2010 13:36, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello > > is there any way to pass paramters in a more proper way than I do > currently? Since it''s the easiest way I''m just passing them as GET > parameters at the moment for example: > http://localhost:3000/actions/980190963/add_date?t=2010-02-23 > http://localhost:3000/actions/new?at=678542324&t=851829735&tt=Type1 > > I really don''t like that way of passing parameters and doesn''t look very > rails-like. > > So solution I can think of so far is to turn all of these links into > forms with hidden tags but I don''t really like that either even though I > think it''s better than now.I don''t understand what you mean. Even if you use hidden fields the url will still look as in your examples. Or are you actually talking about what the code in your view looks like. If so then, for example, you can just add the parameters in link_to, so for example: link_to ''Some Text'', :controller => ''some_controller'', :action => ''some_action'', :t => ''2010-02-23'', tt => ''Type1'' 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.
Colin Law wrote:> > I don''t understand what you mean. Even if you use hidden fields the > url will still look as in your examples. Or are you actually talking > about what the code in your view looks like. If so then, for example, > you can just add the parameters in link_to, so for example: > link_to ''Some Text'', :controller => ''some_controller'', :action => > ''some_action'', :t => ''2010-02-23'', tt => ''Type1'' > > ColinSorry if didn''t make myself clear. I just wanna get rid of the parameters in the URL and pass them so they''re not in the URL. -- 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.
On 22 February 2010 13:36, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> http://localhost:3000/actions/980190963/add_date?t=2010-02-23 > http://localhost:3000/actions/new?at=678542324&t=851829735&tt> > Anyone knowing a better solution to this?You could customise some nice route mapping, to translate these into pretty urls: http://localhost:3000/actions/980190963/add_date/2010-02-23 http://localhost:3000/actions/new/678542324/851829735 -- 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.
> Sorry if didn''t make myself clear. I just wanna get rid of the > parameters in the URL and pass them so they''re not in the URL.That requires a POST request. If you want an URL that looks something like "actions/new/678542324/851829735/Type1", then you could define a custom route like "map.connect '':controller/:action/:id/:at/:t/:tt''", which would enable you to add more parameters without labeling them in the url itself, but I am not sure how well that works with restful resources. -- 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.
Thanks for the advice. Thought of it as well but isn''t there an unwritten rule of not nesting routes too deep and stuff like that? -- 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.
Heinz Strunk wrote:> Thanks for the advice. Thought of it as well but isn''t there an > unwritten rule of not nesting routes too deep and stuff like that?> map.connect '':controller/:action/:id/:at/:t/:tt'' > > http://localhost:3000/actions/980190963/add_date/2010-02-23 > http://localhost:3000/actions/new/678542324/851829735This is not nesting routes. It''s just mapping a URL with with some parameters. If you have not read this guide I''d suggest doing so. If you have then I''d suggest re-reading it: http://guides.rubyonrails.org/routing.html -- 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.
Thanks, I read it. Makes sense :) Still having some trouble, routes.db: map.connect '':controller/:id/:action/:action_id'' In the html file: link_to atp.name, {:controller => ''activities'', :id => @activity, :action => ''select_characters'', :action_id => atp.id } nor select_characters_activity_path(@activity, {:action_id => atp.id}) works. It still creates: http://localhost:3000/activities/980190963/select_characters?action_id=291929305 URLs. Anyone knows why? Seems fine too me. -- 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.
No one? -- 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 Heinz, On Mon, 2010-02-22 at 19:38 +0100, Heinz Strunk wrote:> No one?Didn''t see your prior post. Repost and maybe I can help. Best regards, Bill -- 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.
Sorry - missed the original post. You want to POST a parameter instead of using GET? From where? A controller? post { :some_action, {:login => "bob", :password => "jones" } From a view - just do a normal form, it defaults to post On Mon, Feb 22, 2010 at 10:38 AM, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> No one? > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
No, I just want to change these URLs: http://localhost:3000/actions/980190963/add_date?t=2010-02-23 http://localhost:3000/actions/new?at=678542324&t=851829735&ttinto: http://localhost:3000/actions/980190963/add_date/2010-02-23 http://localhost:3000/actions/new/678542324/851829735 for better readability. I tried it with: map.connect '':controller/:id/:action/:action_id'' link_to atp.name, {:controller => ''activities'', :id => @activity, :action => ''select_characters'', :action_id => atp.id } or select_characters_activity_path(@activity, {:action_id => atp.id}) but I only get: http://localhost:3000/activities/980190963/select_characters?action_id=291929305 So my question was how to create this kind of link: http://localhost:3000/actions/980190963/add_date/2010-02-23 -- 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.
I tried map.connect ''/actions/:action_id/add_date/:date'', :controller => ''actions'', action => ''add_date'' instead of map.connect '':controller/:id/:action/:action_id'' but that didn''t work cause that''s not what''s not working. I need to know how the link_to has to look like so the link_to URL looks like: http://localhost:3000/actions/980190963/add_date/2010-02-23 -- 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.
On Mon, Feb 22, 2010 at 3:19 PM, Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I tried > map.connect ''/actions/:action_id/add_date/:date'', :controller => > ''actions'', action => ''add_date'' > instead of > map.connect '':controller/:id/:action/:action_id'' > but that didn''t work cause that''s not what''s not working. > > I need to know how the link_to has to look like so the link_to URL looks > like: > http://localhost:3000/actions/980190963/add_date/2010-02-23Use a named route map.add_date_to_action ''/actions/:action_id/add_date/:date'', :controller => ''actions'', action => ''add_date'' And then: link_to "Add", add_date_to_action_url(@action.id, Date.today.to_s) -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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.