Forum: Ruby on Rails Problem with link_to

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
zavulon (Guest)
on 2007-03-13 22:37
Hi all,

I'm modifying the HTML design to fit into my Rails app, and have the
following problem... In HTML, there's a code that says:

<a class="rightareah3" href="#"><h3> Some text stuff here </h3></a>

I'm trying to convert it to Rails code, and have the following:

<div id="rightareah3">
    <h3>
        <%= link_to h (item.title), :action => 'show', :id => item %>
    </h3>
</div>

.. and it doesn't work. If I replace link_to with some plain text, it
works, so I know it's link_to.

I'm using Ruby 1.8.2 and Rails 1.1.0

Your help is GREATLY appreciated, thanks!!!
blaine (Guest)
on 2007-03-13 23:27
(Received via mailing list)
Using Rails 1.2 here replacing your local variable as the instance
@item the follow code worked:

<% @item = 'My Title' %>

<div id="rightareah3">
    <h3>
        <%= link_to h (@item), :action => 'show', :id => 1 %>
    </h3>
</div>

Is your local variable coming from a loop for item?

Blaine
zavulon (Guest)
on 2007-03-13 23:55
blaine wrote:
> Using Rails 1.2 here replacing your local variable as the instance
> @item the follow code worked:
>
> <% @item = 'My Title' %>
>
> <div id="rightareah3">
>     <h3>
>         <%= link_to h (@item), :action => 'show', :id => 1 %>
>     </h3>
> </div>
>
> Is your local variable coming from a loop for item?
>
> Blaine

Thanks Blaine.

I upgraded to rails 1.2, tried the above, and it still didn't work :-(
Yes, my local variable does come from a loop for 'item'.
Nelson H. (Guest)
on 2007-03-14 00:01
>         <%= link_to h (item.title), :action => 'show', :id => item %>

How about:

<%= link_to h (item.title), :action => 'show', :id => item.id %>

Nelson


Basedex - A Collaborative Index to organize and collect everything
related to Ruby on Rails
http://blazingrails.basedex.com/index/8
zavulon (Guest)
on 2007-03-14 04:26
I think I didn't explain my problem correctly. The problem is not that
the link doesn't work, it's that the formatting is not showing up
correctly. I.e. whatever text formatting I put in the "a.rightareah3"
area of CSS file, it's not showing up on resulting HTML.
Nelson H. (Guest)
on 2007-03-14 04:30
zavulon wrote:
> I think I didn't explain my problem correctly. The problem is not that
> the link doesn't work, it's that the formatting is not showing up
> correctly. I.e. whatever text formatting I put in the "a.rightareah3"
> area of CSS file, it's not showing up on resulting HTML.

Ahhh...

<%= link_to h (item.title), { :action => 'show', :id => item}, :id =>
"rightareah3"  %>

Nelson
Nelson H. (Guest)
on 2007-03-14 04:31
Nelson H. wrote:
> zavulon wrote:
>> I think I didn't explain my problem correctly. The problem is not that
>> the link doesn't work, it's that the formatting is not showing up
>> correctly. I.e. whatever text formatting I put in the "a.rightareah3"
>> area of CSS file, it's not showing up on resulting HTML.
>
> Ahhh...
>
> <%= link_to h (item.title), { :action => 'show', :id => item}, :id =>
> "rightareah3"  %>
>
> Nelson

Sorry...that should be

<%= link_to h (item.title), { :action => 'show', :id => item}, :class =>
"rightareah3"  %>

Nelson
zavulon (Guest)
on 2007-03-14 04:44
Nelson H. wrote:
> Nelson H. wrote:
>> zavulon wrote:
>>> I think I didn't explain my problem correctly. The problem is not that
>>> the link doesn't work, it's that the formatting is not showing up
>>> correctly. I.e. whatever text formatting I put in the "a.rightareah3"
>>> area of CSS file, it's not showing up on resulting HTML.
>>
>> Ahhh...
>>
>> <%= link_to h (item.title), { :action => 'show', :id => item}, :id =>
>> "rightareah3"  %>
>>
>> Nelson
>
> Sorry...that should be
>
> <%= link_to h (item.title), { :action => 'show', :id => item}, :class =>
> "rightareah3"  %>
>
> Nelson

That's exactly what I needed! Thank you!! I'm very sorry that I wasn't
clear the first time around.
Raj (Guest)
on 2007-04-29 12:57
how to this with div...I dont have class

how to make div propertie apply to the link_to
????

raj.

>> Nelson
>
> That's exactly what I needed! Thank you!! I'm very sorry that I wasn't
> clear the first time around.
Raj (Guest)
on 2007-04-29 13:13
I got it.

\Raj wrote:
> how to this with div...I dont have class
>
> how to make div propertie apply to the link_to
> ????
>
> raj.
>
>>> Nelson
>>
>> That's exactly what I needed! Thank you!! I'm very sorry that I wasn't
>> clear the first time around.
This topic is locked and can not be replied to.