Bogdan Ionescu
2006-Jan-23 15:50 UTC
[Rails] Using :id=>''something'' vs :mid=>''something'' params
Is there any reason for using :id=>''something'' instead of :mid=>''something'' in link_to or link_to_remote? (well other than generating a nicer link) My tool for analysing apache logs is considering /controller/action/4 as a different link than /controller/action/5, so instead of counting /controller/action it will count every variation of that parameter. Bogdan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060123/9a5a75f0/attachment.html
Tom Ward
2006-Jan-23 16:12 UTC
[Rails] Using :id=>''something'' vs :mid=>''something'' params
> Is there any reason for using :id=>''something'' instead of :mid=>''something'' > in link_to or link_to_remote?Well, if the parameter is an id, its best to call it id. That doesn''t mean rails has to generate routes of the form /controller/action/id, however. Just as you can add extra parts to routes in rails (eg :controller/:action/:year/:month/:day), you could (if you really felt you had to) change the default route in routes.rb to :controller/:action. This will generate urls of the form /controller/action?id=something. Even so, I''d always prefer clean urls over a scheme like this.> My tool for analysing apache logs is considering /controller/action/4 as a > different link than /controller/action/5, so instead of counting > /controller/action it will count every variation of that parameter.I don''t have any experience in log analysis, but surely there''s software that can handle this common url pattern? Tom
Bogdan Ionescu
2006-Jan-23 16:18 UTC
[Rails] Using :id=>''something'' vs :mid=>''something'' params
Thanks, i didn''t think about routes.rb On 1/23/06, Tom Ward <tom@popdog.net> wrote:> > > Is there any reason for using :id=>''something'' instead of > :mid=>''something'' > > in link_to or link_to_remote? > > Well, if the parameter is an id, its best to call it id. That doesn''t > mean rails has to generate routes of the form /controller/action/id, > however. Just as you can add extra parts to routes in rails (eg > :controller/:action/:year/:month/:day), you could (if you really felt > you had to) change the default route in routes.rb to > :controller/:action. This will generate urls of the form > /controller/action?id=something. Even so, I''d always prefer clean > urls over a scheme like this. > > > My tool for analysing apache logs is considering /controller/action/4 > as a > > different link than /controller/action/5, so instead of counting > > /controller/action it will count every variation of that parameter. > > I don''t have any experience in log analysis, but surely there''s > software that can handle this common url pattern? > > Tom > > _______________________________________________ > 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/20060123/3d7b03cd/attachment.html
matthew clark
2006-Jan-23 16:24 UTC
[Rails] Using :id=>''something'' vs :mid=>''something'' params
I ran into the issue last night, but was in a hurry so I just made a note to investigate it today. When I used id for a page with a form, the submit action was incorrect. Like this - <%= link_to("Form", :action=>"form_page", :id=>1) %> That gets you a url like - /controller/form_page/1 then, the form start tag - <%= start_form_tag("form_save") %> will submit to - /controller/form_page/form_save I''m sure my mistake is an obvious one, because this certianly isn''t desired behavior. matt On 1/23/06, Tom Ward <tom@popdog.net> wrote:> > > Is there any reason for using :id=>''something'' instead of > :mid=>''something'' > > in link_to or link_to_remote? > > Well, if the parameter is an id, its best to call it id. That doesn''t > mean rails has to generate routes of the form /controller/action/id, > however. Just as you can add extra parts to routes in rails (eg > :controller/:action/:year/:month/:day), you could (if you really felt > you had to) change the default route in routes.rb to > :controller/:action. This will generate urls of the form > /controller/action?id=something. Even so, I''d always prefer clean > urls over a scheme like this. > > > My tool for analysing apache logs is considering /controller/action/4 > as a > > different link than /controller/action/5, so instead of counting > > /controller/action it will count every variation of that parameter. > > I don''t have any experience in log analysis, but surely there''s > software that can handle this common url pattern? > > Tom > > _______________________________________________ > 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/20060123/51d3dc45/attachment.html
Tom Ward
2006-Jan-23 16:31 UTC
[Rails] Using :id=>''something'' vs :mid=>''something'' params
On 1/23/06, matthew clark <winescout@gmail.com> wrote:> I ran into the issue last night, but was in a hurry so I just made a note to > investigate it today. When I used id for a page with a form, the submit > action was incorrect. Like this - > > <%= link_to("Form", :action=>"form_page", :id=>1) %> > > That gets you a url like - /controller/form_page/1 > > then, the form start tag - > <%= start_form_tag("form_save") %> > > will submit to - /controller/form_page/form_save > > I''m sure my mistake is an obvious one, because this certianly isn''t desired > behavior.Try start_form_tag({:action => "form_save", :id => 1}) Tom