ripe-article-50191
09/29/2022, 10:48 AMimport './js/my_custom.js
3. - In browser sources tool I am able to see localhost:3000>assets>avo.custom-blahblah1234.js
4. - In this .js file I can see my custom functions function my_function(){...}
but if in my custom new file <script>my_fucntion()</script>
doesn't works. In fact, the console prints Uncaught ReferenceError: my_function is not defined
Any idea?lemon-wall-20836
09/29/2022, 10:55 AMlemon-wall-20836
09/29/2022, 10:56 AMdefer: true
on the <%= javascript_include_tag "avo.custom", "data-turbo-track": "reload", defer: true %>
tag, the browser will not load the content untile the page is loadedlemon-wall-20836
09/29/2022, 10:56 AMlemon-wall-20836
09/29/2022, 10:56 AMlemon-wall-20836
09/29/2022, 10:57 AMlemon-wall-20836
09/29/2022, 10:58 AMdefer: true
tag. This way, the function will be available to the custom page but, then you'll be exposed to of performance issues and some other JS side-effectslemon-wall-20836
09/29/2022, 10:58 AMjs
<script>
document.addEventListener('turbo:load', () => {
my_function()
})
</script>
lemon-wall-20836
09/29/2022, 10:58 AMlemon-wall-20836
09/29/2022, 10:59 AMconnect
to the DOM when the page is loadedlemon-wall-20836
09/29/2022, 11:00 AMripe-article-50191
09/29/2022, 11:26 AMlemon-wall-20836
09/29/2022, 11:26 AMripe-article-50191
09/29/2022, 12:07 PMripe-article-50191
09/29/2022, 12:12 PMlemon-wall-20836
09/29/2022, 12:38 PMlemon-wall-20836
09/29/2022, 12:39 PMENV['SECRET_KEY_BASE']
, Rails.application.credentials.secret_key_base
, or Rails.application.secrets.secret_key_base
setlemon-wall-20836
09/29/2022, 12:39 PMlemon-wall-20836
09/29/2022, 12:40 PMbin/rails secret
to generate a new secret and set it to the env
or to the secretslemon-wall-20836
09/29/2022, 12:42 PMlemon-wall-20836
09/29/2022, 12:42 PMripe-article-50191
09/29/2022, 3:01 PMsecret_key_base: d40...
for development, test and productionripe-article-50191
09/29/2022, 3:04 PMripe-article-50191
09/29/2022, 3:49 PMripe-article-50191
09/29/2022, 3:53 PMripe-article-50191
09/29/2022, 3:55 PMlemon-wall-20836
09/29/2022, 6:59 PMlemon-wall-20836
09/29/2022, 6:59 PMlemon-wall-20836
09/29/2022, 7:00 PMripe-article-50191
09/30/2022, 6:50 AMdocker-compose up
ripe-article-50191
09/30/2022, 6:52 AMhttp://localhost:3000/en/avo/resources/projects/new
or http://..../1/edit
the system works fineripe-article-50191
09/30/2022, 6:52 AMripe-article-50191
09/30/2022, 6:55 AMripe-article-50191
09/30/2022, 7:54 AMlemon-wall-20836
09/30/2022, 7:54 AMlemon-wall-20836
09/30/2022, 7:54 AMlemon-wall-20836
09/30/2022, 7:55 AMlemon-wall-20836
09/30/2022, 7:55 AMlemon-wall-20836
09/30/2022, 7:56 AMripe-article-50191
09/30/2022, 9:23 AMripe-article-50191
09/30/2022, 11:07 AMlemon-wall-20836
09/30/2022, 11:18 AMlemon-wall-20836
09/30/2022, 11:18 AMRails.application.secrets.secret_key_base
lemon-wall-20836
09/30/2022, 11:18 AMRails.application.credentials.secret_key_base
lemon-wall-20836
09/30/2022, 11:19 AMlemon-wall-20836
09/30/2022, 11:19 AM[ENV['SECRET_KEY_BASE'], Rails.application.credentials.secret_key_base, Rails.application.secrets.secret_key_base].inspect
lemon-wall-20836
09/30/2022, 11:19 AMlemon-wall-20836
09/30/2022, 11:19 AMlemon-wall-20836
09/30/2022, 11:19 AMlemon-wall-20836
09/30/2022, 11:20 AMlemon-wall-20836
09/30/2022, 11:20 AMlemon-wall-20836
09/30/2022, 11:20 AMlemon-wall-20836
09/30/2022, 11:22 AMripe-article-50191
09/30/2022, 11:24 AMripe-article-50191
09/30/2022, 11:34 AMlemon-wall-20836
09/30/2022, 11:34 AMlemon-wall-20836
09/30/2022, 11:35 AMripe-article-50191
09/30/2022, 11:35 AMripe-article-50191
09/30/2022, 11:36 AMlemon-wall-20836
09/30/2022, 11:36 AMripe-article-50191
09/30/2022, 11:36 AMlemon-wall-20836
09/30/2022, 11:46 AMlemon-wall-20836
09/30/2022, 11:46 AMlemon-wall-20836
09/30/2022, 12:04 PM[ENV['SECRET_KEY_BASE'], Rails.application.credentials.secret_key_base, Rails.application.secrets.secret_key_base].inspect
lemon-wall-20836
09/30/2022, 1:22 PMlemon-wall-20836
09/30/2022, 1:23 PMENV['SECRET_KEY_BASE']
has a dummy value foosecretkey
which is lower than 32 characters. that's why it was failinglemon-wall-20836
09/30/2022, 1:43 PMENV['SECRET_KEY_BASE']
value so Rails.application.secrets.secret_key_base
be available for the appripe-article-50191
09/30/2022, 2:35 PMripe-article-50191
09/30/2022, 2:37 PMlemon-wall-20836
09/30/2022, 2:38 PM