# Using :id=\>'something' vs :mid=\>'something' params

**URL:** <https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470>\
**Category:** Rails\
**Created:** [January 23, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470 "2006-01-23T16:53:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bogdan\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@Bogdan\_I](https://www.ruby-forum.com/u/Bogdan_I)\
**Post date:** [January 23, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470/1 "2006-01-23T16:53:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bogdan\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@Bogdan\_I](https://www.ruby-forum.com/u/Bogdan_I)\
**Post date:** [January 23, 2006, 5:12pm UTC](https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470/2 "2006-01-23T17:12:48Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![Bogdan\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@Bogdan\_I](https://www.ruby-forum.com/u/Bogdan_I)\
**Post date:** [January 23, 2006, 5:19pm UTC](https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470/3 "2006-01-23T17:19:06Z")

</div>

Thanks, i didn’t think about routes.rb

---

<div class="post-metadata">

**Author:** ![Bogdan\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@Bogdan\_I](https://www.ruby-forum.com/u/Bogdan_I)\
**Post date:** [January 23, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470/4 "2006-01-23T17:35:06Z")

</div>

On 1/23/06, matthew clark [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![Bogdan\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@Bogdan\_I](https://www.ruby-forum.com/u/Bogdan_I)\
**Post date:** [January 23, 2006, 5:25pm UTC](https://www.ruby-forum.com/t/using-id-something-vs-mid-something-params/64470/5 "2006-01-23T17:25:40Z")

</div>

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
