Comments (10)
Interesting idea! I'll have a look and see what that would look like.
from mobility.
@simonknoll I see the problem. You need to enable fallbacks on the model in order to set them in the getter, otherwise the Mobility::Backend::Fallbacks
module will not be included.
So if you define the Contribution
model this way, it will work:
class Contribution < ApplicationRecord
include Mobility
translates :landing_page, type: :string, fallbacks: true
end
Note that if you then want somewhere else not to use fallbacks for landing_page
, you'll need to pass fallback: false
, i.e. contribution.landing_page(fallback: false)
.
We probably need a way to include the module, but disable it by default. I'm thinking about a natural interface for that...
from mobility.
Actually I'm noticing an issue with 0.1.7 which is causing lots of bogus warnings in the logs. I'll fix it tomorrow and release a new version. (Working on this on this branch.)
Also, I should be able to change the API so that it includes the fallbacks module by default, but only actually uses it if when fallback: ...
is passed to the getter. But I want to think about this a bit more before making that change.
from mobility.
👍 thanks for considering!
from mobility.
@simonknoll see #9.
from mobility.
Thank you so much, this makes my live much easier!
from mobility.
#9 has been merged, closing this.
from mobility.
@shioyama I tried now with version 0.1.7
but I can't get it working. Maybe I'm using it not as intended. Anyways I've created a simple test project with a rspec test. This is the repository https://github.com/simonknoll/mobility-fallback
Cheers,
Simon
from mobility.
Thank you for the clarification @shioyama!
from mobility.
@simonknoll try version 0.1.10 (had to yank 0.1.8 + 0.1.9...).
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.