1

I've just upgraded my Rails app from v5.2.3 to v6.0.0.beta3. I'm using the Daterangepicker v3.0.3 gem and it seems to be incompatible with Rails 6.x. My app depends on the gem and I'd really like to stick with it if possible (how?) and if not, then what gem would substitute it?

I changed my Rails gem version to edge and ran bundle update. It output the following:

Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    jquery-datatables-rails (~> 3.4) was resolved to 3.4.0, which depends on
      actionpack (>= 3.1)

    rails (~> 6.0.0.beta3) was resolved to 6.0.0.beta3, which depends on
      actionpack (= 6.0.0.beta3)

Bundler could not find compatible versions for gem "activemodel":
  In Gemfile:
    rails (~> 6.0.0.beta3) was resolved to 6.0.0.beta3, which depends on
      activemodel (= 6.0.0.beta3)

    web-console (>= 3.3.0) was resolved to 3.7.0, which depends on
      activemodel (>= 5.0)

Bundler could not find compatible versions for gem "activerecord":
  In Gemfile:
    friendly_id (~> 5.2.4) was resolved to 5.2.5, which depends on
      activerecord (>= 4.0.0)

    pg_search (~> 2.1, >= 2.1.5) was resolved to 2.1.5, which depends on
      activerecord (>= 4.2)

    rails (~> 6.0.0.beta3) was resolved to 6.0.0.beta3, which depends on
      activerecord (= 6.0.0.beta3)

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    jbuilder (~> 2.5) was resolved to 2.8.0, which depends on
      activesupport (>= 4.2.0)

    pundit was resolved to 2.0.1, which depends on
      activesupport (>= 3.0.0)

    rails (~> 6.0.0.beta3) was resolved to 6.0.0.beta3, which depends on
      activesupport (= 6.0.0.beta3)

Bundler could not find compatible versions for gem "countries":
  In Gemfile:
    countries

    country_select (~> 3.1) was resolved to 3.1.1, which depends on
      countries (~> 2.0)

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    bootstrap-daterangepicker-rails (~> 3.0, >= 3.0.3) was resolved to 3.0.3, which depends on
      railties (>= 4.0, < 5.3)

    coffee-rails (~> 4.2) was resolved to 4.2.2, which depends on
      railties (>= 4.0.0)

    devise (~> 4.5) was resolved to 4.6.2, which depends on
      railties (>= 4.1.0, < 6.0)

    jquery-rails (~> 4.3, >= 4.3.3) was resolved to 4.3.3, which depends on
      railties (>= 4.2.0)

    momentjs-rails (~> 2.17, >= 2.17.1) was resolved to 2.20.1, which depends on
      railties (>= 3.1)

    rails (~> 6.0.0.beta3) was resolved to 6.0.0.beta3, which depends on
      railties (= 6.0.0.beta3)

    sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
      railties (>= 4.0.0, < 6)

    web-console (>= 3.3.0) was resolved to 3.7.0, which depends on
      railties (>= 5.0)

I commented out my Daterangepicker gem and bundle update worked flawlessly. I see that the gem depends on railties < 5.3, >= 4.0. Rails v6 uses railties > v4, which is likely the reason why it throws out an error. What can I do about this?

Thank you in advance.

Oliver Curting
  • 782
  • 6
  • 12

3 Answers3

1

It is worth noting that sass-rails has the railties version locked to < 6 as well.

I'd be surprised if this changed as most of the Rails world is moving to webpacker for all things front end (everything that used to live in the asset pipeline). It would be worth looking at something like react-rails which would allow you to use react-bootstrap-daterangepicker.

Either that or you could always PR/fork the Daterangepicker gem. Although, based on the (in)frequency of commits and longstanding PRs, I think you might have better luck going the webpacker route.

kyleboe
  • 157
  • 1
  • 8
0

I know it's not the best solution, but I solved it like this:

Gemfile:

gem 'bootstrap-daterangepicker-rails', git: 'https://github.com/jordanbrock/bootstrap-daterangepicker-rails.git', branch: 'master'

If you are afraid of pointing to master, you can also point to the latest commit like this:

gem 'bootstrap-daterangepicker-rails', git: 'https://github.com/jordanbrock/bootstrap-daterangepicker-rails.git', ref: '6cade9deedfca1e6e55ce68b7c828f001e13f995'
bonafernando
  • 1,048
  • 12
  • 14
0

I wouldn't suggest you to use a gem with javascript dependencies, because Rails is moving (as already did on Rails 6) to use Webpack as pre-processor for CSS & Javascript. A better solution to work with Javascript/Jquery dependencies on Rails, besides using frameworks as Vue.js, Angular and React, is to load Jquery globally using Webpack. That way, you can have bootstrap & bootstrap-datepicker on your application, as they both exists as yarn/npm packages. You also can have Jquery functions working with your application.

Here is a SO link about setting up Jquery globally with Webpack

Pedro Gabriel Lima
  • 1,122
  • 1
  • 9
  • 24