Problem with link_to


#1

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:

Some text stuff here

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

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

… 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!!!


#2

Using Rails 1.2 here replacing your local variable as the instance
@item the follow code worked:

<% @item = ‘My Title’ %>

<%= link_to h (@item), :action => 'show', :id => 1 %>

Is your local variable coming from a loop for item?

Blaine


#3

blaine wrote:

Using Rails 1.2 here replacing your local variable as the instance
@item the follow code worked:

<% @item = ‘My Title’ %>

<%= link_to h (@item), :action => 'show', :id => 1 %>

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 :frowning:
Yes, my local variable does come from a loop for ‘item’.


#4
    <%= 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


#5

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.


#6

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


#7

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.


#8

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.


#9

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.


#10

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