Certain js files (datetimepicker) are not loaded in the production environment

Asked 1 years ago, Updated 1 years ago, 28 views

We are currently developing with rails 5.06, and we have placed the necessary files for datetimepicker under assembets/javascript and assembets/css, and read them in application.html.haml as follows:

<script src="/assets/jquery.datetimepicker.js"></script>
<script src="/assets/jquery.datetimepicker.full.js">/script>
<link rel="stylesheet" type="text/css" href="/assets/jquery.datetimepicker.css"/>

It works normally in the local environment, but in the production environment, the following error appears:

Failed to load resource: the server responded with a status of 404 (Not Found) jquery.datetimepicker.js 

Failed to load resource: the server responded with a status of 404 (Not Found) jquery.datetimepicker.full.js 

Failed to load resource: the server responded with a status of 500 (Internal Server Error) jquery.datetimepicker.css

When I tried to load another jquery file before, the same phenomenon occurred, so I don't think datetimepicker is the cause, but I would appreciate it if you could let me know if anyone knows.

javascript ruby-on-rails

2022-09-30 11:57

1 Answers

The problem seems to have been how to specify an uncompiled & path.

I instructed them to compile it.

config/initialzers/assets.rb

Rails.application.config.assets.precompile+=%w(jquery.datetimepicker.full.js)

It was solved by calling them with asset_path as shown below!

application.html.haml

#{asset_path'jquery.datetimepicker.js'}


2022-09-30 11:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.