Closed dexterouschen closed 8 years ago
@dexterouschen we require a minimal reproduction of the issue you are experiencing in order to be able to investigate the issue. Have you done any debugging at all? What have you tried? Also, please be careful when formatting issue reports, take time to make it easy for us to help you.
Feel free to request this issue be reopened when you've addressed the above.
@thomasfedb I've tried to follow https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads and produce the same effect but it seemed that uploaded files are not serialized correctly, thus the invalid JSON error.
@thomasfedb I wonder if I've described the issue clearly enough for it to be reopened.
@dexterouschen is there a reason that you're running on the carrierwave master branch?
@thomasfedb I want to try out the multi-file upload functionality so I won't have to implement an intermediate layer to support the implementation in which a model can have multiple files associated to it.
Note: You must specify using the master branch to enable this feature
Now I've already switched back to my previous solution of intermediate layer and everything works fine. But it'd be nicer to have native support of this.
As we were unable to get a minimal reproduction I'm closing this issue.
I'm having this same issue. The code:
class Report < ActiveRecord::Base
mount_uploaders :articles_screenshots, ArticleScreenshotsUploader
serialize :articles_screenshots # this is a text field
end
I have a loop in which I'm setting the array of files:
articles_screenshots << Pathname.new("path-of-file.png").open
And then when I assign and save the record:
self.articles_screenshots = articles_screenshots
save!
I get the error:
ActiveRecord::StatementInvalid: Mysql2::Error: Invalid JSON text: "Invalid value." at position 1 in value (or column) '---
- materiales-cocinas-encimeras.png
'.: UPDATE `reports` SET `articles_screenshots` = '---\n- materiales-cocinas-encimeras.png\n', `updated_at` = '2016-02-10 20:48:32' WHERE `reports`.`id` = 5
from /vendored_gems/ruby/2.2.0/gems/mysql2-0.4.1/lib/mysql2/client.rb:85:in `_query'
from /vendored_gems/ruby/2.2.0/gems/mysql2-0.4.1/lib/mysql2/client.rb:85:in `block in query'
from /vendored_gems/ruby/2.2.0/gems/mysql2-0.4.1/lib/mysql2/client.rb:84:in `handle_interrupt'
from /vendored_gems/ruby/2.2.0/gems/mysql2-0.4.1/lib/mysql2/client.rb:84:in `query'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:305:in `block in execute'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
from /vendored_gems/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:305:in `execute'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/mysql2_adapter.rb:252:in `exec_delete'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:114:in `update'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `update'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:88:in `_update_record'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/persistence.rb:515:in `_update_record'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/locking/optimistic.rb:79:in `_update_record'
... 19 levels...
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:291:in `block in save!'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:220:in `transaction'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
from /vendored_gems/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:291:in `save!'
from (irb):28
from /vendored_gems/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
from /vendored_gems/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
from /vendored_gems/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
from /vendored_gems/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /vendored_gems/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
I'm using Rails 4.2.5, MySQL 5.7.10 and the master branch for carrierwave.
Any ideas?
@pacuna this issue is closed. Feel free to open a new issue if you've found a bug or need assistance.
I've tried to follow https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads (which means I'm using master branch from Github) and produce the same effect but it seemed that uploaded files are not serialized correctly, thus the invalid JSON error. Both create and update won't work.
my gem setup