# How to use singularize method

**URL:** <https://www.ruby-forum.com/t/how-to-use-singularize-method/117931>\
**Category:** Rails\
**Created:** [October 22, 2007, 3:59pm UTC](https://www.ruby-forum.com/t/how-to-use-singularize-method/117931 "2007-10-22T15:59:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 22, 2007, 3:59pm UTC](https://www.ruby-forum.com/t/how-to-use-singularize-method/117931/1 "2007-10-22T15:59:33Z")

</div>

Hello

I need to know how to make use of singularize method with params[:path],

the code is something like this

\<%= params[:path] %\> , the output of this particular statement is  
computers and I need to get computer.

Thank you

Advait

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 23, 2007, 3:08pm UTC](https://www.ruby-forum.com/t/how-to-use-singularize-method/117931/2 "2007-10-23T15:08:30Z")

</div>

like this

\<%= params[:path].singularize %\>

On Oct 22, 2:59 pm, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 25, 2007, 4:16pm UTC](https://www.ruby-forum.com/t/how-to-use-singularize-method/117931/3 "2007-10-25T16:16:54Z")

</div>

nas wrote:

> like this
> 
> \<%= params[:path].singularize %\>
> 
> On Oct 22, 2:59 pm, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Respected sir,

I tried out and it worked fine,

I have another issue related to using java scripts in rhtml," focusing  
issue ",that is when ever I load a web page my cursor should start  
blinking on the first text field.

I need to know a method to use it individually for rhtms and partials ,  
as I tried out using prototype.js method.

ANY HELP IN THIS MATTER WILL BE VERY VERY HELPFULL

Regards

Advait

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 31, 2007, 2:18pm UTC](https://www.ruby-forum.com/t/how-to-use-singularize-method/117931/4 "2007-10-31T14:18:17Z")

</div>

add this in between your rhtml tag

Add the above script after you have included your prototype.js file

Then use this in your body tag

where your\_field is the id of the field where you want your cursor to  
focus on page load

Hope this helps

On Oct 25, 2:16 pm, Advait B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![advait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e19adc/32.png) [@advait](https://www.ruby-forum.com/u/advait)\
**Post date:** [October 31, 2007, 2:21pm UTC](https://www.ruby-forum.com/t/how-to-use-singularize-method/117931/5 "2007-10-31T14:21:48Z")

</div>

a correction on the first line for the above post  
add this in your rhtml file or in between your layout’s head tag i.e.
