title: Rails 4 Paperclip with Devise, file saving error
body: <p>I'm using devise gem with paperclip to handle authentication and upload pictures. Problem is that I have used paperclip on the same model twice for storing two pictures (let's call those paperclip columns :avatar , :superbadge), my model name is User. </p>
  
  <p>Now, when I choose to upload two pictures, my rails application ignores the first file that I have chosen, instead It uses second chosen file and saves it in the <b>first paperclip column, leaving second paperclip column blank</b>. How do I fix it?</p>
  
  <p>My application controller:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery with: :exception
  
    before_action :configure_devise_permitted_parameters, if: :devise_controller?
  
    protected
  
      def configure_devise_permitted_parameters
          registration_params = [:name, :email, :password, :password_confirmation,:avatar,:superstarbadge]
  
          if params[:action] == "update"
            devise_parameter_sanitizer.for(:account_update) {
              |u| u.permit(registration_params &lt;&lt; :current_password)
            }
          elsif params[:action] == "create"
            devise_parameter_sanitizer.for(:sign_up) {
              |u| u.permit(registration_params)
            }
          end 
      end
  end
  </code></pre>
  
  <p>My User.rb model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    devise :database_authenticatable, :registerable, :validatable
    has_attached_file :avatar, :styles =&gt; { :small =&gt; "100x100&gt;" }
    validates_attachment_content_type :avatar, :content_type =&gt; /\Aimage\/.*\Z/
  
    has_attached_file :superstarbadge, :styles =&gt; { :tiny =&gt; "100x100&gt;" }, :default =&gt; "superbadge.jpg" 
    validates_attachment_content_type :superstarbadge, :content_type =&gt; /\Aimage\/.*\Z/
  
    has_many :questions
    has_many :answers
  
    def to_s
      email
    end
  end
  </code></pre>
  
  <p>My form_for for creating new user with devise gem (I'm using slim template language not erb):</p>
  
  <pre><code>h1 Sign up
  
  = form_for(resource, as: resource_name, url: registration_path(resource_name), :html =&gt; { :multipart =&gt; true }) do |f|
    = devise_error_messages!
  
    .field
      label= f.label :name
      = f.text_field :name, autofocus: true
  
    .field
      label= f.label :email
      = f.email_field :email, autofocus: true
  
    .field
      label= f.label :password
      = f.password_field :password, autocomplete: 'off'
  
    .field
      label= f.label :password_confirmation
      = f.password_field :password_confirmation, autocomplete: 'off'
  
    .field
      = f.label :avatar
      = f.file_field :avatar
  
    .field 
      = f.file_field :avatar
  
    div
      = f.submit "Sign up"
  </code></pre>