variables in views

26 views
Skip to first unread message

fugee ohu

unread,
Feb 27, 2016, 10:14:38 PM2/27/16
to Ruby on Rails: Talk

I'm trying to build some links from this statement   <% for task in row_tasks %> where  task.name and task.name.thumb are full path image file names and not having any luck
I've been trying to link to the image from the thumb I've tried with helpers and basic html something like this ... <a href = "#{@image_path}" ><%= image_tag("#{@thumb_path}") %></a> and i've tried the same with link_to image_tag How am i gonna do this?

Tamara Temple

unread,
Feb 27, 2016, 11:08:35 PM2/27/16
to rubyonra...@googlegroups.com
This should work I would think, given what you say above:

<% for task in row_tasks do %>
<a href="<%= image_tag(task.name)%>"><%= image_path(task.name.thumb) %></a>
<% end %>


--
Tamara Temple
tam...@gmail.com
http://www.tamouse.org

fugee ohu

unread,
Feb 27, 2016, 11:20:26 PM2/27/16
to Ruby on Rails: Talk

Hi Tam, Do I need the do ?

fugee ohu

unread,
Feb 27, 2016, 11:29:18 PM2/27/16
to Ruby on Rails: Talk
That doesn't work and putting the <% %> markups into the value of href= I get a headache looking at it


On Saturday, February 27, 2016 at 11:08:35 PM UTC-5, tamouse wrote:

fugee ohu

unread,
Feb 27, 2016, 11:37:03 PM2/27/16
to Ruby on Rails: Talk


On Saturday, February 27, 2016 at 11:08:35 PM UTC-5, tamouse wrote:

Hi again and thanks again Tam I got it working like this
 <td><a href= "<%= task.name %>"><%= image_tag(task.name.thumb) %></a></td>

Colin Law

unread,
Feb 28, 2016, 4:41:28 AM2/28/16
to Ruby on Rails: Talk
On 28 February 2016 at 04:37, fugee ohu <fuge...@gmail.com> wrote:
> ..
> Hi again and thanks again Tam I got it working like this
> <td><a href= "<%= task.name %>"><%= image_tag(task.name.thumb) %></a></td>
>

Unless I am missing something, this might be clearer
<td>
<%= link_to image_tag(task.name.thumb), task.name %>
</td>

Colin

fugee ohu

unread,
Feb 28, 2016, 3:04:26 PM2/28/16
to Ruby on Rails: Talk


On Saturday, February 27, 2016 at 11:08:35 PM UTC-5, tamouse wrote:

thank you

fugee ohu

unread,
Feb 28, 2016, 3:04:53 PM2/28/16
to Ruby on Rails: Talk

thank you
Reply all
Reply to author
Forward
0 new messages