Reputation: 3462
A Book has_many jackets, and I've got a nested form to add them. I'd like to have a thumbnail image in each set of form fields of the right jacket. What's the best way to get the current jacket in the book's edit view?
books_controller.rb
def edit
@book = Book.find(params[:id])
end
_jacket_fields.html.haml partial
.nested-fields
= f.inputs do
= f.input :image, :as => :file, :label => "File name"
- jacket = # what could go here?
- if jacket
= image_tag jacket.image.url(:thumb)
Upvotes: 2
Views: 711