Ruby on Rails: “couldn't find file 'jquery-ui'”

后端 未结 4 1575
梦如初夏
梦如初夏 2021-02-05 10:16

I\'ve just done a fresh install and was able to access the default rails page at localhost:3000, but when I installed the activeadmin gem I had a problem when accessing /admin/

相关标签:
4条回答
  • 2021-02-05 10:32

    If you are using later versions of jquery-ui-rails in my case jquery-ui-rails-5.0.0

    I found out in the jquery-ui-rails-5.0.0 assets folder, that writing the following line into your application.css:

    *= require jquery-ui
    

    fetches all ui elements for your css, it simply calls:

    *= require jquery-ui/all
    

    and if you write the following into your application.js

    //= require jquery-ui
    

    it fetches most jquery js files, with exception of some specific datepickers, there is no #all method for jquery in application.js, in most cases these would do, but if not, then you can add the rest diretcly into applications.js e.g

    //=require jquery-ui/datepicker-ru
    

    So in summary to use all ui for both css and js

    *= require jquery-ui
    //= require jquery-ui
    
    0 讨论(0)
  • 2021-02-05 10:37

    I would suggest updating your application.js from: //= require jquery_ui to //= require jquery.ui.all as the preferable solution (rather than using an outdated version of the gem).

    0 讨论(0)
  • 2021-02-05 10:41

    This is a known issue due to the jquery-rails dependency dropping jQuery-UI support. The workaround for the moment appears to be to force the jquery-rails gem to load using version 2.3.0:

    gem 'jquery-rails', '~> 2.3.0'
    

    A related problem due to this: Debug jQueryUI Versions in Rails.

    0 讨论(0)
  • 2021-02-05 10:56

    Adding the jquery-ui-rails gem will also give you jquery.ui support.

    gem 'jquery-ui-rails'
    

    In your application.js and application.css files, you can add all modules

    jquery.ui.all
    

    or only the ones you need, e.g.:

    jquery.ui.slider
    
    0 讨论(0)
提交回复
热议问题