我在实施图库方面遇到了问题。它总是向我显示这个错误:
#
的未定义方法`geometry'我读了它,我知道这意味着什么......但我正在做正确的迭代:
<% @gallery_photos.each do |g| %>
无论如何,这里是gallery_detail的代码和方法gallery_detail ......
https://gist.github.com/899049
另外,我正在尝试遵循这种旋转器模型,但我认为我没有以正确的方式进行,因为它在拇指图像上有一个必须与img src匹配的href元素。 ..无论如何,这是我想要遵循的模型:
http://designm.ag/tutorials/image-rotator-css-jquery/
更新:我解决了图像的问题,但我仍然不知道如何实现页面的jquery部分。图像拇指的href必须与main_page div中图像的图像源匹配。
答案 0 :(得分:0)
如果你试试这个怎么办?
def gallery_detail
@gallery_photos = GalleryPhoto.all
end
并在html中:
<div class="main_page">
<% if @gallery_photos.first.geometry == 'vertical' %>
<img src="<%= gallery_photos.first.photo.url("large") %>" style="height:420px;" />
<% else %>
<img src="<%= gallery_photos.first.photo.url("large") %>" style="width:500px;" />
<% end %>
<div class="desc">
<a href="#" class="collapse">Close Me!</a>
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</div>
</div>
<div class="image_thumb">
<ul>
<li>
<% @gallery_photos.each do |g| %>
<% if g.geometry == 'vertical' %>
<a href="#"> <img src="<%= g.photo.url("small") %>" style="height:65px;"/></a>
<% else %>
<img src="<%= g.photo.url("small") %>" style="height:65px; width:80px;"/></li></a>
<% end %>
<% end %>
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</li>
</ul>
</div>
答案 1 :(得分:0)
不是第12行失败
<% if @gallery_photos.geometry == 'vertical' %>
而不是第33行?我不认为它与你迭代集合有关。第12行看起来像是试图直接在GalleryPhoto
s。