0
votes

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

1

1 Answers

0
votes

You could check this other post save image from url by paperclip they explain how to insert a picture from an url.

But actually I think this will try to upload the image.