回形针的导轨问题
我安装了宝石回形针并进行了设置。我将这段代码放入我的一个控制器中,
@pictures = Picture.near([latitude, longitude], 6.8) #im also using geocoder
@picturethumbs = @pictures
@picturethumbs.each do |thumb|
thumb.photo = thumb.photo(:thumb)
end
when i do this in my view
<% @picturethumbs.each do |picture| %>
<p> <%= link_to image_tag(picture.photo), picture_path(picture) %>
</p><% end %>
我得到了常规大小的图像。 如果我不在控制器中调整大小,但在视图中执行 picture.photo(:thumb) 操作,我会得到正确的拇指。您能帮助我独立于在视图中修改图像来调整图像大小吗?也许是另一个与图片相对应但自动包含拇指的模型(不在视图中调整大小)
I installed the gem paperclip and set it up. I put this piece of code in one of my controllers
@pictures = Picture.near([latitude, longitude], 6.8) #im also using geocoder
@picturethumbs = @pictures
@picturethumbs.each do |thumb|
thumb.photo = thumb.photo(:thumb)
end
when i do this in my view
<% @picturethumbs.each do |picture| %>
<p> <%= link_to image_tag(picture.photo), picture_path(picture) %>
</p><% end %>
i get regular sized images.
If i dont resize in my controller, but i do picture.photo(:thumb) in the view i get the right thumbs. Could you help me resize the image independently of modifying it in the view. Maybe another model which corresponds to pictures but contains automatically thumbs (not resizing in view)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否发布有关如何设置您的模型(使用回形针)的更多详细信息?
您将在您的模型中需要它:
然后在您的视图中:
检查此 RailsCast:
http://railscasts.com/episodes/134-paperclip
http://asciicasts.com/episodes/134-paperclip
Can you please post more details on how your Model is set up, which uses paperclip?
You will need this in your model :
and then in your view:
Check this RailsCast:
http://railscasts.com/episodes/134-paperclip
http://asciicasts.com/episodes/134-paperclip