comfy / comfortable-mexican-sofa

ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
MIT License
2.73k stars 640 forks source link

Paperclip error while uploading file #460

Closed zenkovnick closed 10 years ago

zenkovnick commented 10 years ago

I have some problems using Ruby 2.0.0-p353, Rails 4.0.0 and Comfortable Mexican Sofa while uploading files to the CMS page. I got Paperclip::Errors::MissingRequiredValidatorError

Part of backtrace

Paperclip::Errors::MissingRequiredValidatorError (Paperclip::Errors::MissingRequiredValidatorError):
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/attachment.rb&amp;line=396&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/attachment.rb:396:in `ensure_required_validations!'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/attachment.rb&amp;line=97&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/attachment.rb:97:in `assign'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/has_attached_file.rb&amp;line=66&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/has_attached_file.rb:66:in `block in define_setter'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb&amp;line=42&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:42:in `public_send'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb&amp;line=42&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:42:in `_assign_attribute'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb&amp;line=29&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:29:in `block in assign_attributes'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb&amp;line=23&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:23:in `each'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb&amp;line=23&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/attribute_assignment.rb:23:in `assign_attributes'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/core.rb&amp;line=192&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/core.rb:192:in `initialize'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/inheritance.rb&amp;line=27&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/inheritance.rb&amp;line=27&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/inheritance.rb:27:in `new'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/reflection.rb&amp;line=189&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/reflection.rb:189:in `build_association'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/associations/association.rb&amp;line=242&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/associations/association.rb:242:in `build_record'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/associations/collection_association.rb&amp;line=461&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/associations/collection_association.rb:461:in `block in create_record'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/associations/collection_association.rb&amp;line=152&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/associations/collection_association.rb:152:in `block in transaction'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb&amp;line=202&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb&amp;line=210&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb&amp;line=202&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/activerecord-4.0.0/lib/active_record/transactions.rb&amp;line=209&amp;column=1">/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in `transaction'</a>

As far as I have understood - there is a problem with Paperclip ContentType validation. If I use paperclip as standalone with my models - I can provide "validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]" or "do_not_validate_attachment_file_type :image" What should I config to prevent validation in CMS?

GBH commented 10 years ago

Should be fixed now. Try it with master branch: https://github.com/comfy/comfortable-mexican-sofa/commit/30bb618d5bc4a0f1a2b19962037c85896f08c4ad

zenkovnick commented 10 years ago

Now I'm getting NoMethodError (undefined method `gsub' for #Pathname:0x00000008767700)

NoMethodError (undefined method `gsub' for #<Pathname:0x00000008767700>):
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb&amp;line=33&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb:33:in `block in interpolate'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb&amp;line=32&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb:32:in `each'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb&amp;line=32&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb:32:in `inject'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb&amp;line=32&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/interpolations.rb:32:in `interpolate'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/attachment.rb&amp;line=479&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/attachment.rb:479:in `interpolate'</a>
  <a href="txmt://open?url=file:///home/zenkovnick/.rvm/gems/ruby-2.0.0-p353@hub/gems/paperclip-4.1.1/lib/paperclip/attachment.rb&amp;line=167&amp;column=1">/gems/paperclip-4.1.1/lib/paperclip/attachment.rb:167:in `path'</a>
GBH commented 10 years ago

I can't replicate this error. What are you trying to upload and do you have any custom paperclip settings?

zenkovnick commented 10 years ago

yes, I had custom Paperclip settings, works fine now, thanks

rskelley9 commented 10 years ago

I'm having the same problem but with a Rails 3.2.11 project. I can't update the gem to the 1.12.1 version because it relies on Rails 4. How do I fix this?

danieldekay commented 10 years ago

just explicitly load paperclip in your gemfile: gem 'paperclip', '~> 3.4.0'

Fyang0219 commented 9 years ago

I am using 'comfortable_mexican_sofa', '1.11.0' gem in rails 4 existing application. I got Paperclip::Errors::MissingRequiredValidatorError.How can I fix the this bug without create any disturbance on application.

GBH commented 9 years ago

@Fyang0219 Bump CMS to 1.11.2 for the fix.

Fyang0219 commented 9 years ago

i am done override files controller and model in existing application. use cms version 1.11.2 code thanks