Skip to content

Instantly share code, notes, and snippets.

@mdunbavan
Created September 29, 2014 15:08
Show Gist options
  • Select an option

  • Save mdunbavan/79a16b614459dd524e24 to your computer and use it in GitHub Desktop.

Select an option

Save mdunbavan/79a16b614459dd524e24 to your computer and use it in GitHub Desktop.
Images to gallery upload params
# form to add images to the gallery
<%= f.simple_fields_for :gallery do |builder| %>
<%= builder.input :name %>
<%= render 'galleries/form', :f => builder %>
<% end %>
def book_params
params.require(:book).permit(:title, :synopsis, :body, :age, :publisher, :jacket_cover, :story_id, :author_id, :school, schools_attributes: [:id, :school, :address, :school_name, :website, :_destroy], author_attributes: [:name,:biography], gallery_attributes: [:name, images: [ :image[:file] ] ] )
end
{"utf8"=>"✓",
"authenticity_token" => "hZQNoChpQ5gl+sXOZZzo1Tjo5HODfiDcmrBA8LXn4w0=",
"book" => {
"jacket_cover"=>#<ActionDispatch::Http::UploadedFile:0x00000103c63370 @tempfile=#<File:/var/folders/mf/srx7jt8s2rdg0mn5hr98cvz80000gn/T/RackMultipart20140929-30270-92ugm5>, @original_filename="BmYbsf3CYAAxVJG.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"book[jacket_cover]\"; filename=\"BmYbsf3CYAAxVJG.jpg\"\r\nContent-Type: image/jpeg\r\n">,
"title" => "A booker book",
"synopsis" => "<p>z`xx`zz~X`X</p>\r\n",
"body" => "<p>`X~ZX~`Xx`</p>\r\n",
"age" => "11-14",
"publisher" => "Thames & Hudson",
"schools_attributes" => {
"0" => {
"school_name"=>"a school",
"address"=>"49 lambs conduit street london wc1n 3ng"}
},
"author_id"=>"24",
"gallery_attributes" => {
"name" => "the album",
"images_attributes" => {
"1412002788629" => { "file"=>#<ActionDispatch::Http::UploadedFile:0x0000010a921480 @tempfile=#<File:/var/folders/mf/srx7jt8s2rdg0mn5hr98cvz80000gn/T/RackMultipart20140929-30270-1lqwnsd>, @original_filename="46246205_1caa2bcb16_o.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"book[gallery_attributes][images_attributes][1412002788629][file]\"; filename=\"46246205_1caa2bcb16_o.jpg\"\r\nContent-Type: image/jpeg\r\n">},
"1412002794270" => { "file"=>#<ActionDispatch::Http::UploadedFile:0x0000010a91ab30 @tempfile=#<File:/var/folders/mf/srx7jt8s2rdg0mn5hr98cvz80000gn/T/RackMultipart20140929-30270-ebp2lx>, @original_filename="BmYbsf3CYAAxVJG.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"book[gallery_attributes][images_attributes][1412002794270][file]\"; filename=\"BmYbsf3CYAAxVJG.jpg\"\r\nContent-Type: image/jpeg\r\n">}
}
}
},
"commit"=>"Create Book", "action"=>"create", "controller"=>"books"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment