views:

718

answers:

3

I'm using slimbox2 with rails. To make it work you include some markup as follows:

<a href="resources/images/weight1.jpg" rel="lightbox-a" title="Beautiful, isn't it?">a</a> 

<a href="resources/images/example.jpg" rel="lightbox-a" title="Beautiful, isn't it?">a</a>

So I'm wondering, how do you grab the location of the image to place in the href? Relative addressing? Is their a helper that is useful in this situation?

A: 

You could use something like this. The helper is marginally useful. Honestly, unless there's some dynamic component, there's nothing wrong with just using HTML

link_to("a","/resources/images/weight1.jpg", :rel=>"lightbox-a", :title=>"Beautiful, isn't it?")

If the image is dynamic, you could always assign a variable with the path to the image (determined how you like)

<a href="<%= @image_path %>" rel="lightbox-a" title="Foo" />a</a>
Scott
+1  A: 

You want the path of an image? You might try the aptly named #image_path helper method.

BJ Clark
A: 

Well, assuming the images were in your public/images folder, you could achieve that with something like

<%= link_to 'a', image_path('weight1.jpg'), :rel => 'lightbox-a', :title => 'some title' %>
Callmeed