Question

I have a fancy box gallery on an index page. The gallery consists of the instance @gallery which is a model for all images that are supposed to be in the gallery. The gallery shows once a link is clicked.

I also have three studios on that specific page that I would like to add to the gallery. Obviously a studio is a different model. Right now I can get it to where if I click on one of these three studio images, it will open up the fancybox gallery (and will be associated with all of the gallery images because of the :rel => "studio_images" and :class => "grouped_elements").

Right now here in my code for the three studios, I have it linking to the root path but would like those links to link to the image itself:

<%= link_to image_tag(studio.image_url.to_s), root_path, :class => "studio_image grouped_elements", :rel => "studio_images" %><br>

Is there a way rather than saying root_path I can say something like:

studio.image_url.to_s_path?

Was it helpful?

Solution

Sure - interpolate it:

<%= link_to image_tag(studio.image_url.to_s), studio.image_url.to_s, :class => "studio_image grouped_elements", :rel => "studio_images" %><br>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top