Coder Social home page Coder Social logo

Comments (4)

jonian avatar jonian commented on August 27, 2024

It seems that the problem is in mobility/lib/mobility/active_record/uniqueness_validator.rb line 14.

if relation.exists?
  error_options = options.except(:case_sensitive, :scope, :conditions)
  error_options[:value] = value

  record.errors.add(attribute, :taken, error_options)
end

Using relation.exists? or relation.any? I get the same error. If i use relation.present?, it works as expected.

from mobility.

shioyama avatar shioyama commented on August 27, 2024

Ok I found the root cause.

For the record, it's this line, which checks if the relation responds to a method (mobility_where_chain). Calling respond_to?, which should be fine, actually memoizes an arel object here in AR. This in turn is picked up by assert_mutability! here, which is what's raising the error.

I can fix this by replacing relation.respond_to? by relation.methods.include?, which seems ugly but works. This feels like an AR bug but I don't know the internals of what must have changed, so not quite sure...

Anyway that change should be relatively harmless and fix the issue in Rails 5.1. 😄

from mobility.

shioyama avatar shioyama commented on August 27, 2024

This should be fixed now on master, please give it a try.

from mobility.

jonian avatar jonian commented on August 27, 2024

@shioyama I confirm that this is working without issues now. Thank you for the quick fix.

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.