{"action":"created","issue":{"url":"https://api.github.com/repos/galetahub/ckeditor/issues/561","labels_url":"https://api.github.com/repos/galetahub/ckeditor/issues/561/labels{/name}","comments_url":"https://api.github.com/repos/galetahub/ckeditor/issues/561/comments","events_url":"https://api.github.com/repos/galetahub/ckeditor/issues/561/events","html_url":"https://github.com/galetahub/ckeditor/issues/561","id":71792816,"number":561,"title":"ActiveRecord::RecordInvalid: Validation failed: Data content type \"inode/x-empty\" is invalid, Data \"inode/x-empty\" is invalid","user":{"login":"heaven","id":126732,"avatar_url":"https://avatars.githubusercontent.com/u/126732?v=3","gravatar_id":"","url":"https://api.github.com/users/heaven","html_url":"https://github.com/heaven","followers_url":"https://api.github.com/users/heaven/followers","following_url":"https://api.github.com/users/heaven/following{/other_user}","gists_url":"https://api.github.com/users/heaven/gists{/gist_id}","starred_url":"https://api.github.com/users/heaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heaven/subscriptions","organizations_url":"https://api.github.com/users/heaven/orgs","repos_url":"https://api.github.com/users/heaven/repos","events_url":"https://api.github.com/users/heaven/events{/privacy}","received_events_url":"https://api.github.com/users/heaven/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-29T06:35:35Z","updated_at":"2015-04-29T06:55:40Z","closed_at":null,"body":"CKEditor 4.1.1\r\n\r\n```\r\n2.1.2 :005 > asset = Ckeditor::Picture.last\r\n  Ckeditor::Picture Load (0.4ms)  SELECT  `ckeditor_assets`.* FROM `ckeditor_assets`  WHERE `ckeditor_assets`.`type` IN ('Ckeditor::Picture')  ORDER BY `ckeditor_assets`.`id` DESC LIMIT 1\r\n => #<Ckeditor::Picture id: 89642, data_file_name: \"sickle.jpg\", data_content_type: \"image/jpeg\", data_file_size: 52393, assetable_id: nil, assetable_type: nil, type: \"Ckeditor::Picture\", width: 355, height: 644, created_at: \"2015-04-29 05:33:27\", updated_at: \"2015-04-29 05:33:27\"> \r\n2.1.2 :006 > asset.data\r\n => #<Paperclip::Attachment:0x007fd6ecc59728 @name=:data, @instance=#<Ckeditor::Picture id: 89642, data_file_name: \"sickle.jpg\", data_content_type: \"image/jpeg\", data_file_size: 52393, assetable_id: nil, assetable_type: nil, type: \"Ckeditor::Picture\", width: 355, height: 644, created_at: \"2015-04-29 05:33:27\", updated_at: \"2015-04-29 05:33:27\">, @options={:convert_options=>{}, :default_style=>:original, :default_url=>\"/assets/nophoto_small.jpg\", :escape_url=>true, :restricted_characters=>/[&$+,\\/:;=?@<>\\[\\]\\{\\}\\|\\\\\\^~%# ]/, :filename_cleaner=>nil, :hash_data=>\":class/:attachment/:id/:style/:updated_at\", :hash_digest=>\"SHA1\", :interpolator=>Paperclip::Interpolations, :only_process=>[], :path=>\":rails_root/public/system/pictures/:id_partition/:style_:basename.:extension\", :preserve_files=>false, :processors=>[:thumbnail], :source_file_options=>{}, :storage=>:filesystem, :styles=>{:content=>\"800>\", :thumb=>\"118x100#\"}, :url=>\"/system/pictures/:id_partition/:style_:basename.:extension\", :url_generator=>Paperclip::UrlGenerator, :use_default_time_zone=>true, :use_timestamp=>true, :whiny=>true, :validate_media_type=>true, :check_validity_before_processing=>true}, @post_processing=true, @queued_for_delete=[], @queued_for_write={}, @errors={}, @dirty=false, @interpolator=Paperclip::Interpolations, @url_generator=#<Paperclip::UrlGenerator:0x007fd6ecc59160 @attachment=#<Paperclip::Attachment:0x007fd6ecc59728 ...>, @attachment_options={:convert_options=>{}, :default_style=>:original, :default_url=>\"/assets/nophoto_small.jpg\", :escape_url=>true, :restricted_characters=>/[&$+,\\/:;=?@<>\\[\\]\\{\\}\\|\\\\\\^~%# ]/, :filename_cleaner=>nil, :hash_data=>\":class/:attachment/:id/:style/:updated_at\", :hash_digest=>\"SHA1\", :interpolator=>Paperclip::Interpolations, :only_process=>[], :path=>\":rails_root/public/system/pictures/:id_partition/:style_:basename.:extension\", :preserve_files=>false, :processors=>[:thumbnail], :source_file_options=>{}, :storage=>:filesystem, :styles=>{:content=>\"800>\", :thumb=>\"118x100#\"}, :url=>\"/system/pictures/:id_partition/:style_:basename.:extension\", :url_generator=>Paperclip::UrlGenerator, :use_default_time_zone=>true, :use_timestamp=>true, :whiny=>true, :validate_media_type=>true, :check_validity_before_processing=>true}>, @source_file_options={}, @whiny=true> \r\n2.1.2 :007 > asset.data.file?\r\n => true \r\n2.1.2 :008 > asset.data.exists?\r\n => true \r\n2.1.2 :009 > asset.valid?      \r\n => false \r\n2.1.2 :010 > asset.errors.messages\r\n => {:data_content_type=>[\"\\\"inode/x-empty\\\" is invalid\"], :data=>[\"\\\"inode/x-empty\\\" is invalid\"]} \r\n2.1.2 :011 > asset.save!\r\n   (0.2ms)  BEGIN\r\n   (0.1ms)  ROLLBACK\r\nActiveRecord::RecordInvalid: Validation failed: Data content type \"inode/x-empty\" is invalid, Data \"inode/x-empty\" is invalid\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/validations.rb:57:in `save!'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/attribute_methods/dirty.rb:29:in `save!'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/transactions.rb:273:in `block in save!'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/transactions.rb:208:in `transaction'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/transactions.rb:326:in `with_transaction_returning_status'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/activerecord-4.1.7/lib/active_record/transactions.rb:273:in `save!'\r\n\tfrom (irb):11\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/railties-4.1.7/lib/rails/commands/console.rb:90:in `start'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/railties-4.1.7/lib/rails/commands/console.rb:9:in `start'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:69:in `console'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/railties-4.1.7/lib/rails/commands/commands_tasks.rb:40:in `run_command!'\r\n\tfrom /Users/heaven/.rvm/gems/ruby-2.1.2@carmen/gems/railties-4.1.7/lib/rails/commands.rb:17:in `<top (required)>'\r\n\tfrom bin/rails:10:in `require'\r\n\tfrom bin/rails:10:in `<main>'2.1.2 :012 >\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/galetahub/ckeditor/issues/comments/97327411","html_url":"https://github.com/galetahub/ckeditor/issues/561#issuecomment-97327411","issue_url":"https://api.github.com/repos/galetahub/ckeditor/issues/561","id":97327411,"user":{"login":"heaven","id":126732,"avatar_url":"https://avatars.githubusercontent.com/u/126732?v=3","gravatar_id":"","url":"https://api.github.com/users/heaven","html_url":"https://github.com/heaven","followers_url":"https://api.github.com/users/heaven/followers","following_url":"https://api.github.com/users/heaven/following{/other_user}","gists_url":"https://api.github.com/users/heaven/gists{/gist_id}","starred_url":"https://api.github.com/users/heaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heaven/subscriptions","organizations_url":"https://api.github.com/users/heaven/orgs","repos_url":"https://api.github.com/users/heaven/repos","events_url":"https://api.github.com/users/heaven/events{/privacy}","received_events_url":"https://api.github.com/users/heaven/received_events","type":"User","site_admin":false},"created_at":"2015-04-29T06:55:40Z","updated_at":"2015-04-29T06:55:40Z","body":"I think you should check for changes first:\r\n```ruby\r\nself.changes\r\n# => \"data_file_name\"=>[nil, \"2015_Profile_Photo.jpg\"]\r\n```\r\n\r\nIf filename changes present (and the new value is not nil) then try `self.file`, otherwise use `self.path` if `self.file?` returns `true`."}}