I get this error:
undefined method `each' for nil:NilClass
Here:
<% @images.each do |image| %>
This is where I populate @images
:
class Users::RegistrationsController < Devise::RegistrationsController
def edit
@images= Dir.glob("public/assets/images/users/#{current_user.id}/med/*")
super
end
...
My upload form:
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {:multipart => true }) do |f| %>
<div class="form-group">
<label for = 'file-upload', class='btn btn-large btn-block btn-info'>
<span class="glyphicon glyphicon-upload" aria-hidden="true"></span> Upload Picture
<%= f.file_field :image, id: "file-upload", onchange: "this.form.submit()" %>
</label>
</div>
<% end %>
I only get this error when i fail paperclip validation (as in image > 1mb)
has_attached_file :image, {styles: { small: "24x24#", med: "100x100#", large: "200x200#" },
:url => "/assets/images/users/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/images/users/:id/:style/:basename.:extension",
:default_url => "/assets/images/users/default/:style/default.png",
:keep_old_files => true}
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
validates_attachment_size :image, :less_than => 1.megabytes
The thing is that I don't see how the file upload fail is supposed to be handled.