WebFaction
Community site: login faq

I'm working on a Ruby on Rails 4.2.5 application, and I'm using gem 'bootstrap-datepicker-rails' 1.5.0

When I'm working on my development server, on the local computer, I can click the text_field and the calendar pops up correctly:

= f.text_field :fecha_raw_begin, class: "puntero", "data-provide" => "datepicker", "data-date-format" => "dd/mm/yyyy", "data-date-autoclose" => "true", "data-date-language" => "es"

Note: My datepicker widget belongs to a form, I want to perform searches between a time span.

But whenever I switch to production mode, deploying on a remote server using Capistrano, I get problems: whenever I click the text_field, the datepicker doesn't pop up.

I have no clue what could be the cause of this strange behaviour, I have another javascript (gem Bootstrap-Image-Gallery-rails '1.0.1.3.1.0' ) that doesn't work on production environment. I know the issue is related with the configuration for development and production environments, because if I edit the myapp/nginx/conf/nginx.conf file to return to development mode, all my javascript files load correctly.

Things that I've already tried are listed below:

  • I precompiled the assets using

rake assets:precompile RAILS_ENV=production

  • I switched off the uglifier gem, in order to better debug my app on the web browser

  • I've completely removed the turbolinks gem, since in the past I've had conflicts between turbolinks and some javascript files: $(document).ready(function() { }

I don't know what else could I do, if you guys need more information in order help me to solve my problem, I'd be glad to provide it to you.

I believe the problem could be on my config/environments/production.rb, here you are a code snippet of the parameters I think are related to my problem.

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Compress JavaScripts and CSS.
  # config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # etc...

end

Best regards,

K

asked 16 Apr '16, 23:27

khf88
1315
accept rate: 0%


We would need to see the error being generated by JavaScript in the DOM. Use a browser such as Google Chrome or Firefox and check the developer console for the error being reported.

permanent link

answered 17 Apr '16, 21:18

johns ♦♦
5.3k212
accept rate: 23%

You are right, I completely forgot to check the developer console, the problem was a missing dependency: Tether.

Thanks for your support!

permanent link

answered 18 Apr '16, 20:12

khf88
1315
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×13
×6
×4
×1

question asked: 16 Apr '16, 23:27

question was seen: 2,992 times

last updated: 18 Apr '16, 20:12

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM