jquery - Carrierwave not saving file on db -


I am trying to upload avatar to my project model, but without success

This is my idea:

  .inbox-body.light-panel% span.blue-light-title Look for your projects and feel #audit_trail_container = form_tag Set_project_logo_project_path (project) ,: method = & gt; Post: Form-control-group .separator-div .fileuploadadvanced.fileuploadadvanced-new {"data-provides" = & gt; "Fileuploadadvanced"}% span.btn.btn-white.btn-file% span.fileuploadadvanced-new% i.fa.fa- Select the paper-clip file% span.fileuploadadvanced- present% i.fa.fa-undo Change = File_field_tag: Avatar, class = & gt; "Upload"% span.fileuploadadvanced- preview% a.close.fileuploadadvanced- exists {"Data-Dismissed" = & gt; "Fileuploadadvanced", href: "#"} = link_to "Save", "#" ,: class = & gt; 'Btn submit-btn btn-cl-info set_project_logo',: Data = & gt; {: Project = & gt; Project.id}  

which goes on this jquery:

  set_project_logo_action = function () {return $ (".set_project_logo"). ('Project' id = $ (this) .data ('project'); selected = $ ("# avatar"). Val (); return $ .post ('/ projects /' + project_id + "/ set_project_logo" , {Selected: selected, type: "file"}, function (data) {if (data. Success) {return document. Location.reload (true);} other {return warning (data panic;)}}); } Other {Warning ("Select an image to be a project's logo"); return event.preventDefault;}}); };  

This method goes to project_controller:

  def set_project_logo set_project @project = @ project.set_project_logo (params) if rendered @ project.save: Json = & gt; {: Success = & gt; True} second render: json = & gt; {: Error = & gt; "There was a problem setting the logo."} End End  

which ultimately leads to the model on this method:

  def set_project_logo (parameter) If the consultation [: selected]. Displayed? And consultation [: type]. Displayed? I also have a line on my model:  mount_uploader: avatar, project avatarupploader  

line self.avatar = Params [: selected] it has been executed, but param [: selected] This is "c: \ fakepath ..". So I'm guessing that I'm missing something because nothing is being saved on DB either on S3

Any help?


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -