Image upload with attachment_fu

I want to be able to edit the uploaded images from attachment_fu. In my
view I do something like this:

Cover
<%= f.file_field :cover %>

and then in my controller, I do something like

@book = Book.new(params[:book].except(:author_ids, :cover))
if !params[:book][:cover].instance_of? String
@cover = Cover.create!(:uploaded_data => params[:book][:cover],
:book_id => @book.id)
end

I just wanted to know if this is the best way to do this or if there is
something I am missing

You’ll want to save the book first so that @book.id will exist.

Other than that, I’m not really sure what you mean about being able to
edit the images.

Are you getting a particular error?

On May 12, 3:41 pm, Matt M. [email protected]

JDevine wrote:

You’ll want to save the book first so that @book.id will exist.

Other than that, I’m not really sure what you mean about being able to
edit the images.

Are you getting a particular error?

On May 12, 3:41 pm, Matt M. [email protected]

Sorry, I forgot to mention that I am saving. I am not getting any
errors, I just wasn’t sure if there was a better way.

What I mean by editing the images is I want to be able to create the
Book with or without an image and update the image at any time.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs