link_to for an entire table row

2,547 views
Skip to first unread message

Henry Collingridge

unread,
Dec 9, 2007, 8:13:22 PM12/9/07
to Ruby on Rails: Talk
Hi,

I need to make an entire table row act as a hyperlink.
In HTML, this would look like this:

<tr onclick="location.href='#'">
<td><%=h object.send('property') %><td>
...
</tr>

What is the best way of writing this in Rails? I could concatenate the
elements together 'manually', but that seems cludgey.

Thanks in advance!

Henry

Ryan Bigg

unread,
Dec 9, 2007, 10:11:27 PM12/9/07
to rubyonra...@googlegroups.com
<tr onclick="location.href='<%= object_path(object) %>'">

At a guess, that is what you want.

Henry Collingridge

unread,
Dec 9, 2007, 11:13:18 PM12/9/07
to Ruby on Rails: Talk
Ah, no, not really.
I am hoping for a Railsy way to have an entire row act as a hyperlink
- e.g. by using link_to.
But using link_to, I can't see how to avoid passing in a load of messy
concatenation for the row.

Cheers,

Henry

On Dec 10, 4:11 pm, "Ryan Bigg" <radarliste...@gmail.com> wrote:
> <tr onclick="location.href='<%= object_path(object) %>'">
>
> At a guess, that is what you want.
>
> On Dec 10, 2007 11:43 AM, Henry Collingridge <henry.collingri...@gmail.com>
> wrote:
>
>
>
>
>
> > Hi,
>
> > I need to make an entire table row act as a hyperlink.
> > In HTML, this would look like this:
>
> > <tr onclick="location.href='#'">
> > <td><%=h object.send('property') %><td>
> > ...
> > </tr>
>
> > What is the best way of writing this in Rails? I could concatenate the
> > elements together 'manually', but that seems cludgey.
>
> > Thanks in advance!
>
> > Henry
>
> --
> Ryan Bigghttp://www.frozenplague.net

Henry Collingridge

unread,
Dec 9, 2007, 11:17:57 PM12/9/07
to Ruby on Rails: Talk
Actually - sorry - that's great! Cheers!

On Dec 10, 4:11 pm, "Ryan Bigg" <radarliste...@gmail.com> wrote:
> <tr onclick="location.href='<%= object_path(object) %>'">
>
> At a guess, that is what you want.
>
> On Dec 10, 2007 11:43 AM, Henry Collingridge <henry.collingri...@gmail.com>
> wrote:
>
>
>
>
>
> > Hi,
>
> > I need to make an entire table row act as a hyperlink.
> > In HTML, this would look like this:
>
> > <tr onclick="location.href='#'">
> > <td><%=h object.send('property') %><td>
> > ...
> > </tr>
>
> > What is the best way of writing this in Rails? I could concatenate the
> > elements together 'manually', but that seems cludgey.
>
> > Thanks in advance!
>
> > Henry
>
> --
> Ryan Bigghttp://www.frozenplague.net
Reply all
Reply to author
Forward
0 new messages