Ruby on Rails
Thursday, January 15, 2015
I've been working on this more and in the console I can copy from one Pin record and save a new pin like this:
r = Pin.new r.image = Pin.find(83).image r.saveI think the issue is that the new pin form requires that an image is chosen from the user's PC before saving the pin. Whatever that function of Paperclip is, I think that is where I'm getting stuck.
On Thursday, January 8, 2015 at 1:41:39 PM UTC-5, Ruby-Forum.com User 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
--
Posted via http://www.ruby-forum.com/.
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+unsubscribe@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/94d97e11-a8e7-4ca7-86b9-cf804d289b84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment