1

I'm currently developping a website using Rails (5.0.2). I'm using Materialize as a framework to make my website pleasant.

I'm having an issue with the DatePicker. I need to initialize it with JQuery with something like that $('#idOfMyDatePicker').pickadate();

It works great in dev environment but as soon as I put it on Heroku, I get this error : Uncaught TypeError: $(...).pickadate is not a function.

You should know that I'm a bit of a newbie in Rails and not an expert in Javascript. That said I investigated a bit and found out that, in dev, when I call $(...).pickadate(); it goes in $.fn[ name ] = function( options, action ). I never saw this kind of declaration before so I don't get how calling pickadate() could result in going there.

In production, this piece of code is also present, but for whatever reason, it doesn't go in there, it just assumes that the function is not defined.

I don't know if it's a problem of Materialize, or the pickadate.js or if I'm including my files the wrong way...

Thanks for your help !

GaldanM
  • 125
  • 2
  • 12

1 Answers1

0

"Is not a function" error means there is something wrong with your script library includes in prod and they are not successfully pointing to the pickadate.js plugin where this function is defined.

l0ul0u
  • 101
  • 5
  • Do you have any idea what or where I'm doing wrong? Everything is set as default and all the require are correctly set in my application.js – GaldanM May 03 '17 at 23:15
  • I would not be able to guess as I don't know the directory layout of your environments. You need to confirm that the file path for pickadate.js is correct in your prod application.js and that the plugin file is actually uploaded. – l0ul0u May 03 '17 at 23:19
  • Ok, I got the production working by copying the content of `config/environments/development.rb` to `config/environments/production.rb` It means that there was something wrong in the production.rb, I'll check every difference between them and comeback here to tell if someone is in the same situation. Thanks for your help anyway ! – GaldanM May 04 '17 at 12:41