0

I am just looking for some clarification with using paperclip for saving images. I am grabbing all my images stored in Flickr using the Flickraw Gem. I am grabbing the url for the image and saving that to my model,

Model

class Portfolio < ActiveRecord::Base
  attr_accessible :taken, :title, :url, :url_large
end

then rendering using the image_tag helper..

Like so

<%= @portfolio.each do |p| %>
  <%= image_tag(p.url_large, :size => "480x480") %>
  <%= p.title %>
<% end %>

So this shows all my photos at 480 x 480.. However I understand that paperclip handles images better?

So i can install paperclip, add :avatar column to my Portfolio model (though ill prob call it photo) and its the next part i want to clarify.

Do i save the url to the image within the :avatar column and then use the paperclip helpers as normal? Im used to uploading physical images to my model using paperclip which generates a file name within that column (well thats from what I can see)

I save the attributes like so at the moment

flickr.photos.search(:user_id => FLICKR_USER_ID).each do |p|
    info = flickr.photos.getInfo(:photo_id => p.id)

    title = info.title
    taken = info.dates.taken
    square_url = FlickRaw.url_s(info)
    original_url = FlickRaw.url_o(info)


    Portfolio.where(title: title, url: square_url, taken: taken, url_large: original_url).first_or_create!

end

So where to save FlickRaw.url_o ?

Can anyone advise if im thinking about this correctly or do i have some things wrong?

Any help appreciated

4

1 回答 1

0

您可以通过回形针检查来自 url 的其他帖子保存图像,他们解释了如何从 url 插入图片。

但实际上我认为这会尝试上传图像。

于 2013-06-27T22:15:03.643 回答