Forum: Ruby on Rails Using :id=>'something' vs :mid=>'something' params

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bogdan I. (Guest)
on 2006-01-23 17:53
(Received via mailing list)
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
Tom W. (Guest)
on 2006-01-23 18:12
(Received via mailing list)
> 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 I. (Guest)
on 2006-01-23 18:19
(Received via mailing list)
Thanks, i didn't think about routes.rb
matthew clark (Guest)
on 2006-01-23 18:25
(Received via mailing list)
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
Tom W. (Guest)
on 2006-01-23 18:35
(Received via mailing list)
On 1/23/06, matthew clark <removed_email_address@domain.invalid> wrote:
>
>  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
This topic is locked and can not be replied to.