Coder Social home page Coder Social logo

Comments (20)

shioyama avatar shioyama commented on August 27, 2024

My guess would be that it's paper trail. What if you remove it and see if you see the same issue?

from mobility.

shioyama avatar shioyama commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

Ah ok it's compatibility with the strip_attributes gem (should be obvious). This is not a bug but a compatibility issue.

from mobility.

shioyama avatar shioyama commented on August 27, 2024

I'm probably going to have to close this since I can't really guarantee compatibility with every other gem.

from mobility.

jmuheim avatar jmuheim commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

@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.

shioyama avatar shioyama commented on August 27, 2024

@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.

jmuheim avatar jmuheim commented on August 27, 2024

I'll do soon, sorry for the delay.

from mobility.

shioyama avatar shioyama commented on August 27, 2024

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.

jmuheim avatar jmuheim commented on August 27, 2024

Thanks a lot for your effort! 👍

from mobility.

jmuheim avatar jmuheim commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

btw, this is a wrap-up of recent changes: http://dejimata.com/2017/12/5/mobility-0-3-ready-for-prime-time

from mobility.

shioyama avatar shioyama commented on August 27, 2024

This is the view code you're talking about right?

from mobility.

jmuheim avatar jmuheim commented on August 27, 2024

from mobility.

shioyama avatar shioyama commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

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.

shioyama avatar shioyama commented on August 27, 2024

@jmuheim ok issue is fixed now, try 0.3.4.

from mobility.

jmuheim avatar jmuheim commented on August 27, 2024

It's working, thank you so much. I love mobility gem. ❤️

from mobility.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.