Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5.1.1 - Photo not displayed in the view when the latter is rendered in AJAX after a photo upload #187

Open
Guillaumejfrt opened this issue Nov 30, 2017 · 1 comment

Comments

@Guillaumejfrt
Copy link

Hi,

I have installed Remotipart to upload photo in AJAX in a simple_form.

When I submit the form, the html.erb view is rendered but the photo is not displayed through the cl_image_tag user.photo. In order to view the photo, I have to reload the html.erb view.

Indeed, when I put a binding.pry in the html.erb view and that I upload a new photo, I do not get a get a Cloudinary object as I should get in the @file attribute.

See below the user.photo object that I get.

[1] pry(#<#<Class:0x007f9d5879d0b8>>)> user.photo
=> #<PhotoUploader:0x007f9d57f75d68
 @cache_id=nil,
 @cache_storage=#<CarrierWave::Storage::File:0x007f9d57f6ff30 @uploader=#<PhotoUploader:0x007f9d57f75d68 ...>>,
 @file=nil,
 @filename="guigui.jpg",
 @metadata=
  {"public_id"=>"feytghfcd61wtovlvix6",
   "version"=>1512059677,
   "signature"=>"dad07181473ccb7b12b7db909737b4ae1ebd4405",
   "width"=>2048,
   "height"=>1366,
   "format"=>"jpg",
   "resource_type"=>"image",
   "created_at"=>"2017-11-30T16:34:38Z",
   "tags"=>[],
   "bytes"=>195392,
   "type"=>"upload",
   "etag"=>"66945ec83d1bc4252cae1b6529979cc8",
   "placeholder"=>false,
   "url"=>"http://res.cloudinary.com/dcbdvdwuo/image/upload/v1512059677/feytghfcd61wtovlvix6.jpg",
   "secure_url"=>"https://res.cloudinary.com/dcbdvdwuo/image/upload/v1512059677/feytghfcd61wtovlvix6.jpg",
   "original_filename"=>"guigui"},
 @model=
  #<User id: 11, first_name: "Guigui", last_name: "Jauffret", photo: "image/upload/v1512059677/feytghfcd61wtovlvix6.jpg", email: "[email protected]", description: "ldkzsfj^kzf,okzr,coezri,ôzeir,cêori,vêorifjezîjfep...", authentication_token: "8SyXkcnqbR-qH3F9q_9u", created_at: "2017-11-20 09:30:18", updated_at: "2017-11-30 16:34:35", city_id: 6, is_admin: true>,
 @mounted_as=:photo,
 @original_filename="guigui.jpg",
 @public_id="feytghfcd61wtovlvix6",
 @storage=#<Cloudinary::CarrierWave::Storage:0x007f9d58155818 @uploader=#<PhotoUploader:0x007f9d57f75d68 ...>>,
 @tags=nil,
 @transformation={},
 @versions={}>

Here is my simple_form code:

 <%= simple_form_for user, html: { multipart: true }, remote: true do |f| %>
    <div class="firstname-info-error"></div>
    <div class="field">
      <label>Prénom:</label>
      <%= f.input :first_name %>
    </div>
    <div class="lastname-info-error"></div>
    <div class="field">
      <label>Nom:</label>
      <%= f.input :last_name %>
    </div>
    <div class="field">
      <label>Photo de profil:</label>
      <%= f.file_field :photo %>
      <%= f.input :photo_cache, as: :hidden %>
    </div>
    <%= button_tag "OK", type: 'submit', class:"ui btn-primary reverse button", data: { disable_with: "<i class='spinner icon'></i>" } %>
<% end %> 

Is a problem of gem or me doing something wrong?

Thanks a lot for your help.
Guillaume

@zhisme
Copy link

zhisme commented Dec 17, 2017

I read description and I see no word about rails 5 maintenance.
It's just for 3, 4 version. And probably gem is no longer maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants