I am having a problem getting dropzone to save to my database. It's showing that the fields are coming in from the logs, but it's not saving.
%section#profile-editor
.row
.small-12.columns
%h2 Edit Profile
.row
.small-12.columns
.well
= form_for(current_artist, url: artist_registration_path, method: 'PUT', html: {multipart: true, class: :dropzone, id: 'photo-dropzone'}) do |form|
.row
.small-4.columns
%input#photo-dropzone{:name => "image", :type => "file"}/
= form.hidden_field :image, value: params[:image]
.small-8.columns
.row
.small-12.columns
= form.label :name
= form.text_field :name
.small-6.columns
= form.label :website_url, "Website URL"
= form.text_field :website_url
.small-6.columns
= form.label :itunes_url, "Itunes URL"
= form.text_field :itunes_url
.small-6.columns
= form.label :video_url, "Youtube Video URL (For Profile)"
= form.text_field :video_url
.small-6.columns
= form.label :email, "Admin Email"
= form.text_field :email
.small-6.columns
= form.label :city, "City"
= form.text_field :city
.small-6.columns
= form.label :state, "State"
= form.text_field :state
.row
.small-12.columns.pad-top
= form.label :about_me, "Content"
= form.text_area :about_me, class: "editor"
= submit_tag "Submit", class: "button button-green"
Log:
Started PUT "/artists" for 127.0.0.1 at 2014-10-07 17:21:00 -0700
Processing by Artists::Devise::RegistrationsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Iok5bGQhzPneeZDGbwayqNR2h4LZRjZrVMqY6n3C7II=", "image"=>#<ActionDispatch::Http::UploadedFile:0x007fa5702d0ab0 @tempfile=#<Tempfile:/var/folders/lr/tmtpfc_n0hvcgtb5mhxymbkh0000gn/T/RackMultipart20141007-18936-80n9dr>, @original_filename="uqM07w8.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"image\"; filename=\"uqM07w8.jpg\"\r\nContent-Type: image/jpeg\r\n">, "artist"=>{"image"=>"", "name"=>"", "website_url"=>"", "itunes_url"=>"", "video_url"=>"", "email"=>"[email protected]", "city"=>"", "state"=>"", "about_me"=>""}, "commit"=>"Submit"}
Artist Load (0.4ms) SELECT "artists".* FROM "artists" WHERE "artists"."id" = 33 ORDER BY "artists"."id" ASC LIMIT 1
Artist Load (0.2ms) SELECT "artists".* FROM "artists" WHERE "artists"."id" = $1 LIMIT 1 [["id", 33]]
(0.1ms) BEGIN
SQL (0.3ms) UPDATE "artists" SET "itunes_url" = $1, "updated_at" = $2 WHERE "artists"."id" = 33 [["itunes_url", ""], ["updated_at", "2014-10-08 00:21:00.192606"]]
(0.4ms) COMMIT
I'm really lost on where to go with this. Something isn't set up right and I cant quite figure it out.
The image attribute inside the artist param collection ( "artist"=>{"image"=>""} ) is actually blank, that's why the attach is not saved. Try changing this line:
%input#photo-dropzone{:name => "image", :type => "file"}
To:
%input#photo-dropzone{:name => "artist[image]", :type => "file"}
That should force the image attribute to go inside the artist collection in the params.
Let me know if that helps.