Comments (3)
Unfortunately, I think this is Rails/AR making the kind of thing that Mobility does (defining dynamic attributes that map to different persistence locations) more difficult. Rails 5.1 already made simply marking attributes as dirty more difficult for AR models, which Mobility gets around by overriding has_attribute?
.
I'm hesitant to reach too far into AR and override methods to make stuff "work", since it has a tendency to come back to haunt you later. I'm just trying to understand how mutation trackers work to see if we can do anything safely that would make this work... the alternative would just be to override update_attribute
to do something different if the attribute is translated, but this approach is a bit like playing whack-a-mole, since if the core dirty issue is not resolved the same problem will again come up somewhere else.
from mobility.
I personally wouldn't go the overwriting route, as I agree it will lead to maintenance issues going forward. Taking a look at it in more detail, I think Rails current handling is actually a bug. They added a check that is no longer necessary. rails/rails#27780 is a PR to fix this behaviour in Rails, and if it is merged, this should work in mobility.
It also isn't such a big deal if the update_attribute
method doesn't work with mobility. Normally, I don't think you'd use it with the kind of attributes you want to translate it, I just happened to be using it in my specs, in a place that I could have used update_attributes
instead.
At the moment, if someone was using update_attribute
, they'd have to rewrite it from article.update_attribute :title, "foo"
to
article.title = "foo"
article.save(validate: false)
Given this, I'll close this issue.
from mobility.
Thanks! Agree that it's not worth implementing. Hopefully Rails will merge that PR.
from mobility.
Related Issues (20)
- Not compatible with FastGettext - request for string available locale support HOT 2
- Error when installing on Vitess MySQL db HOT 4
- The presence plugin doesn't work as expected HOT 1
- Destruction of record+translations fails, when model IDs are of the type "varchar(36)" (a UUID string) HOT 3
- accessor super method doesn't work with arguments like class.value(locale: :de) HOT 1
- ordering by specific locale HOT 2
- Add type checking plugin reference HOT 3
- eager_load and pluck builds the wrong query HOT 1
- `i18n` scope incompatible with `exists?` HOT 1
- validates presence: true failing with cache active HOT 3
- Empty content row is created in translation table. HOT 1
- No fixtures are generated / No doc on how to make them ourselves HOT 2
- Not working properly with Rails 7.1.1 HOT 1
- Cannot inject the query when using query method block HOT 2
- Allow composite foreign keys HOT 3
- Mobility with active_storage for translatable attachements HOT 1
- 1.3.0.rc1 Can't assign an translated attribute with a column fallback HOT 2
- Fallbacks in runtime HOT 1
- Migration from `globalize`: foreign keys
- table fallbacks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobility.