Coder Social home page Coder Social logo

Comments (13)

shioyama avatar shioyama commented on August 27, 2024 1

Released 0.2.1 with these fixes: https://rubygems.org/gems/mobility/versions/0.2.1

from mobility.

jnylen avatar jnylen commented on August 27, 2024

@shioyama,
This also seems to be happening:
/home/vagrant/.rvm/gems/ruby-2.3.3/bundler/gems/mobility-d58081ef2e2f/lib/mobility/backends/sequel/pg_hash.rb:42:in `block in class:PgHash': uninitialized constant Mobility::Sequel::ColumnChanges (NameError)

(dont mind that its from github, it also happened with the one on rubygems)

Initalizer:

Mobility.configure do |config|
  config.default_backend = :jsonb
  config.accessor_method = :translates
  config.query_method    = :i18n
end

from mobility.

shioyama avatar shioyama commented on August 27, 2024

Thanks, about the first warning, I'm guessing that Mobility is able to load 'rails' but then something fails to load after that, probably 'rails/generators'. The result would be that it sets Mobility::Loaded::Rails first to true, then back to false.

I can't imagine that rails would be included in your application... does require 'rails' raise a LoadError from console with your Gemfile?

from mobility.

jnylen avatar jnylen commented on August 27, 2024

Hi @shioyama,
It raises:
=> false

I have these "rails" gems in the lockfile:
rails-dom-testing
railties
rails-html-sanitizer

Any idea how to fix the Mobility::Sequel::ColumnChanges one?

from mobility.

shioyama avatar shioyama commented on August 27, 2024

Ok, then I see the issue. The core problem is that ruby doesn't have "optional dependencies", so the way gems typically do this is to try requiring a dependency, and catch the LoadError if it fails to load. But in this case you have rails, but not another dependency, so this breaks down.

I can this I think, I'll just need to require the generators separately and not assume they are bundled with rails.

The second issue is just a missing requires in "mobility/backends/sequel/pg_hash". Can you try pointing to the require_column_changes branch?

from mobility.

shioyama avatar shioyama commented on August 27, 2024

I've merged the branch into master, if you use the latest the ColumnChanges issue should be fixed.

from mobility.

shioyama avatar shioyama commented on August 27, 2024

Also, I realized the other warning issue is because in your case you have "rails", but not "activerecord", whereas the rails generators assume that AR is loaded. This is an issue of how things are required, I'll fix it in the next day or two and release a new version. Thanks for pointing out the issue!

Let me know if the other (second) issue is fixed on master.

from mobility.

shioyama avatar shioyama commented on August 27, 2024

Try the load_rails branch which has fixes for both issues.

from mobility.

jnylen avatar jnylen commented on August 27, 2024

@shioyama,
load_rails fixed both.

But a 2 new errors occur. If I dont add data to a jsonb that was created with:
jsonb :synopsis

It will say: Sequel::Error: The AND operator requires at least 1 argument

If I add data to the only 2 jsonb columns in the model (Sequel::Model) it gives.

2.3.3 :004 > 
m.synopsis = "test"
 => "test" 
2.3.3 :005 > m.save
Sequel::DatabaseError: PG::DatatypeMismatch: ERROR:  column "synopsis" is of type jsonb but expression is of type boolean
LINE 1: ...gas" ("synopsis", "title", "created_at") VALUES (('en' = 'te...
                                                             ^
HINT:  You will need to rewrite or cast the expression.

And the model:

  translates :title, type: :string
  translates :synopsis, type: :text

from mobility.

shioyama avatar shioyama commented on August 27, 2024

@jnylen Are you sure the column is of type jsonb? What does your schema look like?

from mobility.

shioyama avatar shioyama commented on August 27, 2024

Oh never mind...

from mobility.

jnylen avatar jnylen commented on August 27, 2024

By the way,
Here are the sequel related gems in Gemfile:

    sequel (4.49.0)
    sequel-annotate (1.0.0)
      sequel (>= 4)
    sequel-rake (0.1.0)
      thor (~> 0.19)
    sequel_pg (1.7.0)
      pg (>= 0.8.0)
      sequel (>= 4.0.0)
    sequel_polymorphic (0.3.1)
      sequel (~> 4)
    sequel_sluggable (0.0.6)
      sequel (>= 3.0.0)

from mobility.

shioyama avatar shioyama commented on August 27, 2024

I'm going to close this issue and merge the branch since that resolves it. Can you please post a new issue about the jsonb error?

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.