# Id tag assignment with date helper class

**URL:** <https://www.ruby-forum.com/t/id-tag-assignment-with-date-helper-class/73995>\
**Category:** Rails\
**Created:** [October 28, 2006, 10:46pm UTC](https://www.ruby-forum.com/t/id-tag-assignment-with-date-helper-class/73995 "2006-10-28T22:46:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [October 28, 2006, 10:46pm UTC](https://www.ruby-forum.com/t/id-tag-assignment-with-date-helper-class/73995/1 "2006-10-28T22:46:52Z")

</div>

Hi,

How do I assign an id to my select tags generated by the date helper  
like select\_month and select\_time, etc?

Thanks,  
Sam

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [October 29, 2006, 3:51am UTC](https://www.ruby-forum.com/t/id-tag-assignment-with-date-helper-class/73995/2 "2006-10-29T03:51:13Z")

</div>

Sam W. wrote:

> Hi,
> 
> How do I assign an id to my select tags generated by the date helper  
> like select\_month and select\_time, etc?
> 
> Thanks,  
> Sam

Sam, this sounded like an easy thing to look up, but having looked,  
there doesn’t seem to be a direct way to set it.

It seems to me that you might be able to work your way around it with  
something like this (untried), which is just setting a string to the  
result of the helper, and then inserting the usual id=“foo” type thing  
into the string before outputting that to the html…

\<% my\_select = select\_month %\>  
\<%= my\_select.gsub(/select /,"select id=‘foo’ " %\>

This is just a guess. Give it a try and let us know if this is a  
workable solution. Note the lack of an = on the first line, it  
shouldn’t create any output into the html stream. The second line does  
have an =, so it should take the result of the gsub and “publish it” to  
the html page.

best,  
jp

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [October 29, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/id-tag-assignment-with-date-helper-class/73995/3 "2006-10-29T20:25:42Z")

</div>

On Oct 28, 2006, at 7:51 PM, Jeff P. wrote:

> Sam, this sounded like an easy thing to look up, but having looked,  
> This is just a guess. Give it a try and let us know if this is a  
> workable solution. Note the lack of an = on the first line, it  
> shouldn’t create any output into the html stream. The second line  
> does  
> have an =, so it should take the result of the gsub and “publish  
> it” to  
> the html page.
> 
> best,  
> jp

```
Yeah it's kinda lame that the date_select helper does nt allow you

```

to assign your own id’s or classes. I gt around it by using some JS  
to add class names to the date selects. So you can put this in your  
view below the date\_select call:

Maybe that points you in the right direction.

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [October 29, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/id-tag-assignment-with-date-helper-class/73995/4 "2006-10-29T20:44:06Z")

</div>

This did it. Thank you so much.

Sam

Jeff P. wrote:

> It seems to me that you might be able to work your way around it with  
> something like this (untried), which is just setting a string to the  
> result of the helper, and then inserting the usual id=“foo” type thing  
> into the string before outputting that to the html…
> 
> \<% my\_select = select\_month %\>  
> \<%= my\_select.gsub(/select /,"select id=‘foo’ " %\>
> 
> This is just a guess. Give it a try and let us know if this is a  
> workable solution. Note the lack of an = on the first line, it  
> shouldn’t create any output into the html stream. The second line does  
> have an =, so it should take the result of the gsub and “publish it” to  
> the html page.
> 
> best,  
> jp
