-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encoding trouble when creating an ActiveRecord object. #68
Comments
I guess you're storing an image or something along with some UTF-8 data in the database? Is that correct? |
yes! what should i do? |
@tenderlove, could you help me to fix this bug? tell me where i look, how it could be solved this issue.. i could make the code and pull request. thanks |
You cannot concatenate UTF-8 and binary data. ARel is building a SQL statement, and that is exactly what is happening. In order to solve this, you have three choices:
This is not an arel bug (unfortunately). |
Hello,
I'm having issues trying to save my rails object.
The exception is:
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
My backtrace says:
[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:69:in
join' [GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:69:in
visit_Arel_Nodes_Values'[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/visitor.rb:15:in
visit' [GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:59:in
visit_Arel_Nodes_InsertStatement'[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/visitor.rb:15:in
visit' [GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/visitor.rb:5:in
accept'[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:18:in
block in accept' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:111:in
with_connection'[GEM_ROOT]/gems/arel-2.0.10/lib/arel/visitors/to_sql.rb:16:in
accept' [GEM_ROOT]/gems/arel-2.0.10/lib/arel/tree_manager.rb:20:in
to_sql'[GEM_ROOT]/gems/arel-2.0.10/lib/arel/select_manager.rb:217:in
insert' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/relation.rb:14:in
insert'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/persistence.rb:274:in
create' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/timestamp.rb:47:in
create'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/callbacks.rb:277:in
block in create' [GEM_ROOT]/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:414:in
_run_create_callbacks'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/callbacks.rb:277:in
create' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/persistence.rb:250:in
create_or_update'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/callbacks.rb:273:in
block in create_or_update' [GEM_ROOT]/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:444:in
_run_save_callbacks'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/callbacks.rb:273:in
create_or_update' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/persistence.rb:40:in
save'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/validations.rb:43:in
save' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/attribute_methods/dirty.rb:21:in
save'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:240:in
block (2 levels) in save' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:292:in
block in with_transaction_returning_status'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
transaction' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:207:in
transaction'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:290:in
with_transaction_returning_status' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:240:in
block in save'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:251:in
rollback_active_record_state!' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:239:in
save'app/controllers/lambs_controller.rb:245:in
block in create' [GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
transaction'[GEM_ROOT]/gems/activerecord-3.0.9/lib/active_record/transactions.rb:207:in
transaction' app/controllers/my_controller.rb:229:in
create'i'm using ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux] and adjusted the encoding as utf-8 either on database.yml and my_controller.rb with (#encoding:utf-8)
How to solve this issue?
thank you.
The text was updated successfully, but these errors were encountered: