I use Dragonfly for image processing in a Rails 3.1 application. I am struggling with assigning model images using URLs.
I have this working tone in the form:
<%= form_for [@word, @game, @picture], :html => {:multipart => true} do |f| %>
<%= f.hidden_field :retained_image %>
<p>
<%= f.label :image, "upload pic" %><br />
<%= f.file_field :image %>
</p>
<p>
<%= f.label :image_url, "or pic URL" %><br />
<%= f.text_field :image_url %>
</p>
<p>
<% if @picture.image_uid? %>
<label>Remove Picture?</label>
<%= f.check_box :remove_image %>
<% end %>
</p>
<p><%= f.submit %></p>
<% end %>
Dragonfly documentation says:
Dragonfly provides an accessory for assignment directly from the URL:
@album.cover_image_url = 'http://some.url/file.jpg'
But still, when I try in the console,
=> #<Picture id: nil, game_id: nil, user_id: nil, created_at: nil, updated_at: nil, image_uid: nil>
ruby-1.9.2-p290 > picture.image_url = "http://i.imgur.com/QQiMz.jpg"
=> "http://i.imgur.com/QQiMz.jpg"
ruby-1.9.2-p290 > picture
=> #<Picture id: nil, game_id: nil, user_id: nil, created_at: nil, updated_at: nil, image_uid: nil>
It seems to be returning the URL string that I am trying to pass to Dragonfly, but not opening and stretching the image, as in the form.
Is there something I don't see when trying to assign an image based on the url? It seems like this should be pretty straight forward, but I can't get anything to work on the ruby console.