Comments (20)
My guess would be that it's paper trail. What if you remove it and see if you see the same issue?
from mobility.
Hmm I'm not sure what's going wrong. I can see the error running your code, but removing all other stuff from the model it still occurs. However I don't see it in isolated Mobility specs, so something in your projects setup or gemfile is conflicting I would suppose...
from mobility.
Ah ok it's compatibility with the strip_attributes
gem (should be obvious). This is not a bug but a compatibility issue.
from mobility.
I'm probably going to have to close this since I can't really guarantee compatibility with every other gem.
from mobility.
Thanks a lot for finding the problem.
Do you have a more specific guess on what's the problem with strip_attributes
gem? I will create an issue on its side then.
from mobility.
@jmuheim can you try pointing your Gemfile to the branch in #102 ?
gem 'mobility', github: 'shioyama/mobility', branch: 'convert_attributemethods_to_plugin'
This branch extracts the code overriding the attributes
hash into a plugin which is not enabled by default. I believe this should fix the problem with strip_attributes
.
from mobility.
@jmuheim See above, can you please try using the branch in #102? I am going to merge that branch to fix the issue here.
from mobility.
I'll do soon, sorry for the delay.
from mobility.
I've merged #102. If you use the latest on master
now, you should not have any conflict with strip_attributes
anymore.
This will be released shortly as a change in 0.3.
from mobility.
Thanks a lot for your effort! 👍
from mobility.
Hey there!
I tried to use the master branch, and while the problem disappeared, a spec failed.
The spec checks that each translated column offers a small icon next to the input. This icon is added in a custom SimpleForm input:
if object.respond_to?(:translated_attribute_names) && object.translated_attribute_names.include?(attribute_name.to_s)
help_blocks << template.content_tag(:span, nil, class: 'fa fa-globe') + ' ' + t('simple_form.inputs.better_text.multi_language')
end
It seems that in the master branch the object doesn't respond to :translated_attribute_names
anymore. But in the source the method still exists, so I'm unsure why it doesn't work like this anymore.
I'm using 0.2.3
until I can fix this.
Any help is highly appreciated.
from mobility.
Hmm, I've checked and for me, using the latest (0.3.3) the model instance responds to translated_attribute_names
.
Are you sure that your model instance really doesn't respond to translated_attribute_names
? Maybe it's something to do with simple form.
from mobility.
I notice the problem is (possibly) connected to paper trail. I was actually thinking of creating a small gem for using mobility with paper trail.
I'm suspecting the issue might be because the attributes
method on the model no longer includes translated attributes in 0.3.x.
Can you try setting attribute_methods
to true
in your config, like this:
Mobility.configure do |config|
config.default_backend = :column
config.accessor_method = :translates
config.query_method = :i18n
config.default_options[:fallbacks] = { de: :en }
config.default_options[:attribute_methods] = true
end
?
from mobility.
btw, this is a wrap-up of recent changes: http://dejimata.com/2017/12/5/mobility-0-3-ready-for-prime-time
from mobility.
This is the view code you're talking about right?
from mobility.
from mobility.
Ok I've confirmed this issue in your repository, and indeed adding attribute_methods: true
to the config fixes it (but brings back the original issue you posted here). I'm debugging now, very strange...
from mobility.
Ah, never mind, I see the issue. translated_attribute_methods
is still in Mobility, but only on the model class, not on the instance, see here. This should really not be extracted into the plugin.
I'll fix this and release a new patch version. Thanks for noticing the issue!
from mobility.
@jmuheim ok issue is fixed now, try 0.3.4.
from mobility.
It's working, thank you so much. I love mobility gem. ❤️
from mobility.
Related Issues (20)
- 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
- Testing and fixtures
- Column fallback to original value every time there's no translation present HOT 2
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.