-
Notifications
You must be signed in to change notification settings - Fork 92
Closed
Description
When trying to use the i18n helper, an error is raised TypeError: Cannot visit Mobility::Arel::Nodes::Json
Context
We are using mobility with MySQL 5.7 and JSON columns and ActiveRecord 5.2.2. When I try to use the i18n helper, I get an exception:
[1] pry(main)> Product.i18n.find_by(name: "Shirt")
TypeError: Cannot visit Mobility::Arel::Nodes::Json
from /usr/local/bundle/gems/arel-9.0.0/lib/arel/visitors/reduce.rb:21:in `rescue in visit'
Caused by NoMethodError: undefined method `visit_Mobility_Arel_Nodes_Json' for #<Arel::Visitors::MySQL:0x00007fead9544fe0>
from /usr/local/bundle/gems/arel-9.0.0/lib/arel/visitors/reduce.rb:15:in `visit'
My schema looks like this:
create_table "products", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t|
t.json "name"
end
product.rb model:
class Product < ApplicationRecord
extend Mobility
translates :name
end
Expected Behavior
Return results for multiple languages. The SQL Query could look something like this
SELECT `products`.* FROM `products` WHERE ((name->'$.de' = 'Shirt') OR (name->'$.fr' = 'Shirt'))
Actual Behavior
An error is raised.
Metadata
Metadata
Assignees
Labels
No labels