问题
I have been made a post model with picture upload and attached fancybox to display these pictures and this all works great.
Example:
<div id="pictures_in_form"><%= link_to image_tag(asset.object.image.url(:thumb)), asset.object.image.url(:big), :class => "fancybox", :rel => "gallery" if asset.object.image? %></div>
But when I want to attach a fancybox to a single image, I have error:
The requested content cannot be loaded.
Please try again later.
Example:
<%= link_to (image_tag 'about_school/par_livu_skolu_1.jpg'), '/about_school/par_livu_skolu_1.jpg', :class => "fancybox"%>
So can anyone point to the problem? Thank you!
回答1:
Try moving your opening parens like this:
<%= link_to (image_tag ('about_school/par_livu_skolu_1.jpg'), '/about_school/par_livu_skolu_1.jpg', :class => "fancybox") %>
That might fix it.
回答2:
The first image path starts without slash /
like :
about_school/par_livu_skolu_1.jpg
... so it indicates a relative path. If the calling page, for instance, is located in a subdirectory like :
/mysubdir/page.html
... then the image path will be
/mysubdir/about_school/par_livu_skolu_1.jpg
On the other hand, the second image path does start with slash /
like :
/about_school/par_livu_skolu_1.jpg
...which means that the image path starts from root
regardless where the calling page is located.
I guess you need to correct either path, whatever is correct otherwise fancybox won't find the image and will display the message
The requested content cannot be loaded.
Please try again later.
来源:https://stackoverflow.com/questions/15011694/fancybox-error-in-rails