# Link\_to helper (or some other method) on an entire table row?

**URL:** <https://www.ruby-forum.com/t/link-to-helper-or-some-other-method-on-an-entire-table-row/182173>\
**Category:** Rails\
**Created:** [January 24, 2010, 1:59am UTC](https://www.ruby-forum.com/t/link-to-helper-or-some-other-method-on-an-entire-table-row/182173 "2010-01-24T01:59:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [January 24, 2010, 1:59am UTC](https://www.ruby-forum.com/t/link-to-helper-or-some-other-method-on-an-entire-table-row/182173/1 "2010-01-24T01:59:12Z")

</div>

I’m trying to implement a design handed to me where an entire row of a  
table is a link to view details about the obj shown in that row.

The html handed to me looks like this:

 Person's Name **Home:** Person's Email

note the ‘onclick’ in the

Is there a Rails Way to do this?

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [January 24, 2010, 2:04am UTC](https://www.ruby-forum.com/t/link-to-helper-or-some-other-method-on-an-entire-table-row/182173/2 "2010-01-24T02:04:28Z")

</div>

Never mind. It just dawned on me… For others who may wonder:

Note the url\_for call (in this case on a nested resource)

---

<div class="post-metadata">

**Author:** ![lunaclaire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f4b2a3/32.png) [@lunaclaire](https://www.ruby-forum.com/u/lunaclaire)\
**Post date:** [January 24, 2010, 8:21am UTC](https://www.ruby-forum.com/t/link-to-helper-or-some-other-method-on-an-entire-table-row/182173/3 "2010-01-24T08:21:18Z")

</div>

lunaclaire wrote:

> Never mind. It just dawned on me… For others who may wonder:

Wow! I realize that this HTML was handed to you, but please, never do  
it this way. Problems which you should correct in the interests of  
cleaner markup and better maintainability:

- Inline CSS. Banish the HTML ‘style’ attribute from your repertoire.  
Do all styling with class names. That goes likewise for the styles you  
call from your JavaScript code – it’s better to set this.className than  
this.style.

- Inline JavaScript. HTML should contain _only_ information about the  
logical structure of a document. Styling belongs in a separate CSS  
file, and by the same token, behavior belongs in a separate JavaScript  
file. This has the added benefit of allowing you to use JavaScript like  
a real programming language (which it is!), not an extension bolted onto  
HTML.

- (Potential) lack of degradation. Always try to provide an alternative  
for use when JavaScript is not available. In this case, that probably  
means that you want to make sure some element within the table row in  
question is wrapped in an tag. (In your case, that’s probably  
best done on the name column.)

 
 

If you have any questions about how to do any of these things, let me  
know.

 

> Note the url\_for call (in this case on a nested resource)

 
## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
