Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Paperclip::Errors::MissingRequiredValidatorError in Spree::Admin::StoresController#update #155

Open
W0lfbane opened this issue Sep 4, 2016 · 1 comment

Comments

@W0lfbane
Copy link

W0lfbane commented Sep 4, 2016

Trying to add a new logo for a domain. I am using stable build 3.1. Whenever I attempt to add a logo, I get this error:

Paperclip::Errors::MissingRequiredValidatorError in Spree::Admin::StoresController#update

Extracted source (around line #400):              
    def ensure_required_validations!
      if missing_required_validator?
        raise Paperclip::Errors::MissingRequiredValidatorError
      end
    end

A previous issue submitted by a user shows that adding a validation to store_decorator.rb fixes the problem, however it looks like that already exists in my case:

module Spree
  Store.class_eval do
    has_and_belongs_to_many :products, join_table: 'spree_products_stores'
    has_many :taxonomies
    has_many :orders

    has_many :store_payment_methods
    has_many :payment_methods, through: :store_payment_methods

    has_many :store_shipping_methods
    has_many :shipping_methods, through: :store_shipping_methods

    has_and_belongs_to_many :promotion_rules, class_name: 'Spree::Promotion::Rules::Store', join_table: 'spree_promotion_rules_stores', association_foreign_key: 'promotion_rule_id'

    has_attached_file :logo,
      styles: { mini: '48x48>', small: '100x100>', medium: '250x250>' },
      default_style: :medium,
      url: 'stores/:id/:style/:basename.:extension',
      path: 'stores/:id/:style/:basename.:extension',
      convert_options: { all: '-strip -auto-orient' }

    if respond_to? :logo_file_name
      validates_attachment_file_name :logo, matches: [/png\Z/i, /jpe?g\Z/i]
    end

  end
end

What am I doing wrong?

W0lfbane added a commit to W0lfbane/spree-multi-domain that referenced this issue Sep 6, 2016
@visoft
Copy link

visoft commented Nov 16, 2016

This can be fixed by just including validates_attachment and adding a migration for logo_content_type to the Spree::Store model.

Migration

class AddLogoContentTypeForStore < ActiveRecord::Migration
  def change
    add_column :spree_stores, :logo_content_type, :string
  end
end

store_decorator.rb

Spree::Store.class_eval do
  validates_attachment :logo, content_type: { content_type: %w(image/jpeg image/jpg image/png image/gif) }
end

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

No branches or pull requests

2 participants