sprockets

rails 4 not using digests in asset filenames, but only in production

和自甴很熟 提交于 2021-02-07 08:01:41
问题 The bounty expires in 2 days . Answers to this question are eligible for a +100 reputation bounty. stevec wants to draw more attention to this question: I have a similar problem (albeit slightly less complicated) here: stackoverflow.com/questions/65990841/… Basically assets aren't being given their full url (with digest) in production, so they simply aren't working. The urls are generated in the controller, and image_url() doesn't seem to return the same result from the controller as it does

Serve compiled javascript and css files from rails app for use in external site

时光毁灭记忆、已成空白 提交于 2021-01-29 16:20:42
问题 How can I make some asset files (.js and .css) from my rails app available to another site? Example: // allow this to be added to some external website <link rel="stylesheet" href="https://myrailsapp.com/external/mystyle.css"> <script src="https://myrailsapp.com/external/myscript.js"></script> The js and css files should be compiled by the standard asset pipeline. 回答1: For rails 5 add the desired assets to be precompiled in config/initializers/assets.rb Rails.application.config.assets

How does finger print digest gets calculated in Rails 4.2

徘徊边缘 提交于 2020-12-10 08:57:49
问题 I am using Rails 4.2 and the document states that the fingerprint is an md5 digest calculated based on the content of the compiled file. If we take a file lets say application-4c697a2e67b1a921abbdc1f753c465d8.js , 4c697a2e67b1a921abbdc1f753c465d8 is the md5 digest. The problem is that we are never able to get the same value by generating md5 from the content of the same file. I have read somewhere that this fingerprint is not only based on the file but also affected by the environment along

How does finger print digest gets calculated in Rails 4.2

旧城冷巷雨未停 提交于 2020-12-10 08:56:56
问题 I am using Rails 4.2 and the document states that the fingerprint is an md5 digest calculated based on the content of the compiled file. If we take a file lets say application-4c697a2e67b1a921abbdc1f753c465d8.js , 4c697a2e67b1a921abbdc1f753c465d8 is the md5 digest. The problem is that we are never able to get the same value by generating md5 from the content of the same file. I have read somewhere that this fingerprint is not only based on the file but also affected by the environment along

Configure Cache-Control for specific static resource in Rails

余生颓废 提交于 2020-03-26 03:52:07
问题 I am working on a Rails 4 app that requires serving some static assets under a defined URL. I have removed the digest from the resources as discussed in this thread: Serve compiled javascript and css files from rails app for use in external site Of course this leaves me with the problem that browsers will cache the resources even though they may have been updated. Currently my file is served with the following HTTP Headers: HTTP/1.1 200 OK Server: nginx Date: Thu, 23 Jan 2020 21:45:51 GMT

Rails: Can't render pages, getting JSON parse error

怎甘沉沦 提交于 2020-01-24 17:12:13
问题 I am working on a project that uses a Rails server while using JSPM to organize Javascript files while also using Sprockets to pipeline assets. My rails server works, but I cannot currently render any views. I think this has something to do with sprockets not successfully managing the processors that compiles the JavaScript. (An additional note: the JavaScript is is ES6). What the below error seems to be saying is that the server tries to render the index page, but the JSON is absent because

Sprockets::FileNotFound with ZURB Foundation

℡╲_俬逩灬. 提交于 2020-01-06 01:22:25
问题 When using foundation 4.3.1 on Rails 3.2 I get the following error: Sprockets::FileNotFound in Refinery/pages#home Showing ...../gems/refinerycms-92675b5132ae/core/app/views/refinery/_javascripts.html.erb where line #16 raised: couldn't find file 'foundation' (in ...../app/assets/javascripts/application.js:15) I checked everything, assets are turned on, downgraded to an earlier version of Foundation. But nothing works like it should (I have the same thing running fine with a different Rails

Sprockets generating incorrect logical_path for javascript files

放肆的年华 提交于 2020-01-05 12:16:19
问题 Sprockets seems to make an error in determining the logical_path of my javascript assets (except for application.js). It prepends "../javascripts" to the path and so my references are wrong and the application.js file won't precompile. I'm using Rails Thin server on Windows. Gemfile: source 'http://rubygems.org' gem 'rails', '3.1.3' gem 'eventmachine', '1.0.0.beta.4.1' gem 'thin' gem 'mysql' gem 'win32-open3-19' gem 'paperclip', '2.3.8' gem 'jsmin' gem 'will_paginate' gem 'jquery-rails' #

How to use Sprockets 2 with Rails 3.0.x

我们两清 提交于 2020-01-03 17:14:31
问题 I'm trying to use these gists to get Sprockets 2.0beta to work with a Rails 3.0.5 app in a similar way to how it works natively in Rails 3.1. Failing thoroughly so far--my app is finding the correct routes and files, and loading the initializer that extends Sprockets::Environment, but it's not parsing the //= require 'phu' lines in my application.js. Can anyone enlighten me about Sprockets 2 with Rails 3.0? 回答1: I have used the same gists as a basis, and it works fine. I have made some

How to use Sprockets 2 with Rails 3.0.x

孤者浪人 提交于 2020-01-03 17:14:17
问题 I'm trying to use these gists to get Sprockets 2.0beta to work with a Rails 3.0.5 app in a similar way to how it works natively in Rails 3.1. Failing thoroughly so far--my app is finding the correct routes and files, and loading the initializer that extends Sprockets::Environment, but it's not parsing the //= require 'phu' lines in my application.js. Can anyone enlighten me about Sprockets 2 with Rails 3.0? 回答1: I have used the same gists as a basis, and it works fine. I have made some