Ruby on Rails: "could not find jquery.ui.datepicker file"

Okay, this is driving me crazy. I followed the installation instructions for jQuery datepicker here: http://railscasts.com/episodes/213-calendars-revised , but I get this error:

Sprockets::FileNotFound in Verifications#new couldn't find file 'jquery.ui.datepicker' (in /app/assets/stylesheets/application.css:11) 

Here is application.js:

 //= require jquery //= require jquery.ui.all //= require jquery_ujs //= require_tree . 

Here is application.css:

  *= require jquery.ui.datepicker *= require_self *= require_tree . 

and in the gemfile:

 group :assets do gem 'jquery-ui-rails' end 

Does anyone see what I'm missing?

+6
source share
6 answers

Answering my own question here if someone else makes the same mistake. I restarted the rails server and then it worked.

+17
source

For future readers. First, make sure you restart the rail server after installing gem, as krstck replied.

Then double check the version of your gem. jquery-ui-rails changed its require syntax to 5.0.0 . Now you should write:

 //= require jquery-ui/datepicker 

Also add to css

 *= require jquery-ui/datepicker 
+29
source

adds 'jquery-ui-rails' to your gemfile and uses a hyphen instead of a dot requiring jquery-ui

 //= require jquery-ui 

or downgrade jquery-ui gem version

 gem 'jquery-ui-rails', '~> 4.2.1' 
+8
source

For Rails 5 users to use datepicker jQuery you should add this to your application.js :

 //= require jquery-ui/widgets/datepicker 

And this is for your application.css :

 /* *= require jquery-ui/datepicker */ 

You can also use the regular version of gem:

 gem 'jquery-ui-rails' 

Reboot the server.

Here is the documentation

+6
source

Decreasing from jquery-ui-rails 5.0.0 to 4.2.1 fixed this for me.

+4
source

Just add: I had the same problem, I finally solved it by placing //= require turbolinks before the jquery requirements in application.js :

 //= require turbolinks //= require jquery //= require jquery.ui.datepicker //= require jquery_ujs //= require_tree . 
0
source

Source: https://habr.com/ru/post/955221/


All Articles