koloa
2006-Aug-13 18:35 UTC
[Rails] you can pass multiple parameters using link_to? anything bad
i just found out i can pass mutiple parameters from views like <%= link_to doctype.name, :action => "show_towns", :id => doctype.name, :id2 => doctype.id%> silly me, i always had the impression that i could only pass 1. i guess i dont have to use sessions after all for my site. is there anything wrong with this? basically instead of the user filling out forms(drop down boxes, radio boxes etc), i just what them to click on links that gets passed to the contoller etc...and depending on what the selected, that will be used for the query. is there anything wrong with this approach? thanks. -- Posted via http://www.ruby-forum.com/.
James Schementi
2006-Aug-13 20:19 UTC
[Rails] Re: you can pass multiple parameters using link_to? anything
koloa wrote:> i just found out i can pass mutiple parameters from views like > > > <%= link_to doctype.name, :action => "show_towns", :id => doctype.name, > :id2 => doctype.id%> > > > silly me, i always had the impression that i could only pass 1. i guess > i dont have to use sessions after all for my site. is there anything > wrong with this? > > basically instead of the user filling out forms(drop down boxes, radio > boxes etc), i just what them to click on links that gets passed to the > contoller etc...and depending on what the selected, that will be used > for the query. is there anything wrong with this approach? > > thanks.it''s a fine approach, but just remember that if you don''t define what to do with :id2 in routes.rb, then your url will look something like this: /controller/show_towns/town_name?id2=town_id ~js -- Posted via http://www.ruby-forum.com/.
koloa
2006-Aug-13 23:29 UTC
[Rails] Re: you can pass multiple parameters using link_to? anything
hi james, thanks for the reply. what way should it look like? any samples of what you mean? i am very new to web development. thank you. James Schementi wrote: -- Posted via http://www.ruby-forum.com/.
James Schementi
2006-Aug-14 00:47 UTC
[Rails] Re: you can pass multiple parameters using link_to? anything
koloa wrote:> hi james, thanks for the reply. what way should it look like? any > samples of what you mean? i am very new to web development.It''s fine if the URL looks like that, but if you want a clean url you''ll have to add a rewrite rule in "routes.rb" to look something like this: map.connect '':controller/:action/:id2/:id'' this will turn that link i wrote above into /controller_name/show_towns/town_name/town_id I suggest renaming :id2 to :name or something like that so it makes sense. http://manuals.rubyonrails.com/read/chapter/65 - this is a good explanation of what routes are and why to use them. ~js -- Posted via http://www.ruby-forum.com/.
Brian Hogan
2006-Aug-14 12:26 UTC
[Rails] you can pass multiple parameters using link_to? anything bad
Not really anything technically wrong with the approach but I''ll mention a few things that jump out right away: There is a limit to how long a URL can be... I believe 255 characters max. Also, you don''t want anything in there that can be private data, like passwords. Also keep in mind that it''s easier for people to manipulate URLs than it is to manipulate form data (neither is really that hard) so you may have users ''exploring'' around your site more than normal. I don''t recommend this approach though because it''s really not that flexible. See how far you get though. On 8/13/06, koloa <none@none.com> wrote:> > i just found out i can pass mutiple parameters from views like > > > <%= link_to doctype.name, :action => "show_towns", :id => doctype.name, > :id2 => doctype.id%> > > > silly me, i always had the impression that i could only pass 1. i guess > i dont have to use sessions after all for my site. is there anything > wrong with this? > > basically instead of the user filling out forms(drop down boxes, radio > boxes etc), i just what them to click on links that gets passed to the > contoller etc...and depending on what the selected, that will be used > for the query. is there anything wrong with this approach? > > thanks. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060814/e3f6d131/attachment.html
koloa
2006-Aug-15 12:37 UTC
[Rails] Re: you can pass multiple parameters using link_to? anything
hi brian thanks. since all my table information is public, i guess security is not a major issue? i am just planning on building a little directory for my town so people can search for doctors in the area. -- Posted via http://www.ruby-forum.com/.
J Amiel
2006-Aug-15 14:33 UTC
[Rails] Re: you can pass multiple parameters using link_to? anything
Brian Hogan wrote:> There is a limit to how long a URL can be... I believe 255 characters > max.??? This isn''t true (at least outside the rails world). Most browsers support URL lengths in the thousands of characters... Is their some internal Rails limit that I am not aware of? -- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Aug-15 15:47 UTC
[Rails] Re: you can pass multiple parameters using link_to? anything
J Amiel wrote:> Brian Hogan wrote: >> There is a limit to how long a URL can be... I believe 255 characters >> max. > > ??? This isn''t true (at least outside the rails world). Most browsers > support URL lengths in the thousands of characters...http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html " The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15). Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths. " -- Posted via http://www.ruby-forum.com/.