On 8 January 2015 at 18:41, Tony T. <li...@ruby-forum.com> wrote:
> My site is for posting album reviews, which are called Pins. The pins
> model has the following attributes:
>
> :artist, :year, :title, :rank, :description, and :image
>
> The image uses Paperclip and is stored on Amazon S3 if that matters
>
> I am trying to allow a user to see a review that another user posted and
> click a link to more simply write their own review for that same album.
> So basically the link takes them to the Pin.new page and the form
> already has the :artist, :title, :image, and :year filled in.
>
> I figured out how to do it while bringing all of the attributes that I
> want, but the image doesn't come over to the new form.
>
> Here is the pins_controller.rb code I'm using, which gives me an error
> of "no implicit conversion of URI::Generic into String":
>
>   def copy
>     @source = Pin.find(params[:id])
>     @image = URI.parse(@source.image.url)
>     @pin = Pin.new(artist: @source.artist, album: @source.album, year:
> @source.year, image: @image)
>     render 'new'
>   end
>
> And in my show view:
>
> <%= link_to "copy", copy_pin_path(params[:id]) %>
>
> Attachments:
> http://www.ruby-forum.com/attachment/10385/Screen_Shot_2015-01-08_at_1.39.06_PM.png

For future reference it is better to copy the error text from the
terminal window and paste it here rather than attaching an image, then
I would be able to insert my text at the appropriate point in the
error.

I assume that the image field in the db is a string field.  You are
calling Pin.new with a URI object as the image and the error says that
there is not an implicit way of converting the URI to a string.  I
guess that you want to use @image.to_s in Pin.new.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsakr0TbQxknV_tSqL1Hg6jbHBWF4CRatD7pUps%3DQ0Mnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to