sprockets

assets:precompile fails with “File exists” on Rails 3.2.15 with Asset Pipeline

末鹿安然 提交于 2019-12-11 02:47:40
问题 I am unable to precompile my assets for my Rails 3.2.15 asset pipeline enabled app. Gemfile: # Asset pipeline group :assets do gem 'sass-rails', '3.2.5' gem 'coffee-rails', '3.2.2' gem 'uglifier', '1.3.0' end production.rb # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false # Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false #

calling javascript functions from html in rails 3.1

淺唱寂寞╮ 提交于 2019-12-11 02:24:11
问题 Using coffeescript, jQuery, and sprockets in rails 3.1 the coffeescript files are compiled in to blocks like: (function() { var a; var b; var c; foo = function() { alert("foo"); } bar = function() { alert("bar"); } }).call(this); This seems to move functions foo and bar out of global scope, so bar can be called by foo, but neither can be called from the html code. When I try to call foo from a select onchange element, I get a "Can't find variable: foo". The workaround right now is to move all

sprockets duplicate file naming

孤街醉人 提交于 2019-12-10 21:19:49
问题 I have the following files, in my asset path: javascripts/abc.js templates/abc.js.mustache # this gets compiled to abc.js naturally, they both would be requested as assets/abc.js . Is there a fix? If not, what part of the Sprockets source would need to be modified? My thinking is along the lines that if the engine can remove the extension, it can well enough add a suffix. 回答1: It may be too obvious, but isn't it better just rename files? I understand nature of your question, but it's hard to

sprockets sass partial erb extension

被刻印的时光 ゝ 提交于 2019-12-10 16:21:46
问题 I have noticed that with the latest rails and sprockets versions (3.2.1 & 2.2.0) there seems to be a problem when the erb file extension is added to a sass partial. e.g. if somestylefilename.css.sass is renamed to somestylefilename.css.sass.erb and the file contains a declaration of a sass variable that uses erb, vis:- $background-colour: <%= '#fff' %>; all is ok. However if a sass partial is renamed from say _sharedpartial.css.sass to _sharedpartial.css.sass.erb then the same variable

Rails asset pipeline: how to create custom manifest file

丶灬走出姿态 提交于 2019-12-10 12:35:51
问题 I am trying to make a custom manifest javascript file seperate from application.js. I've take the code from application.js and pasted it into a new file I've called "other_manifest.js" and placed in the assets/javascrips directory. Here is the code: // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets

Getting Sprockets to minify CSS/JS while not in a Rails/Rack app

百般思念 提交于 2019-12-10 11:07:37
问题 I'm trying to use Sprockets to combine and minify my JavaScript and CSS files outside of the Rails and Rack context. So far, I'm able to combine them into a single file, but now I'm trying to run the JS compressor and the CSS compressor on those files. I followed the Sprockets README's instructions (https://github.com/sstephenson/sprockets#minifying-assets), but I'm getting this error: NoMethodError: undefined method `compress' for :uglify:Symbol Here is my complete rakefile: require

Rails jquery-fileupload gem - couldn't find file error

拥有回忆 提交于 2019-12-10 10:25:32
问题 I'm trying to follow the Railscasts episode on jQuery-FileUpload. I've added gem 'jquery-fileupload-rails' to the assets group of the Gemfile , and also added the //= require jquery-fileupload/basic line to the application.js file in the asset directory. When I try to bring up the website, however, the following error is shown: couldn't find file 'jquery-fileupload' (in root/app/assets/javascripts/application.js:15) Any help would be greatly appreciated. 回答1: I found a "solution" - restarting

Sprockets::CircularDependencyError application.js has already been required

断了今生、忘了曾经 提交于 2019-12-10 02:08:27
问题 In my application, I receive a Sprockets::CircularDependencyError application.js has already been required. This affects every page in my application because none of the JS loads. Note - this error occurred after a fairly complex merge. My assumption (please correct me if I'm wrong) is that this error occurs because two different files require application.js. If so, in which files should I look to debug this error? How could I test my application to determine what files are already requiring

Can the rails tmp/cache/assets files be safely deleted?

拈花ヽ惹草 提交于 2019-12-09 14:23:36
问题 I seem to have a TON of them in subfolders named for example sprockets%2F76920e6913c3390459175ac8e6dfd44a3 They seem to contain binary data. What are they for, why are there so many of them and most importantly, can these be safely removed? They take forever to scp. 回答1: Yep! You can delete the whole tmp directory and it will get recreated. 回答2: Yes, you can safely delete it. The best way to delete will be running the following in the rails console: Rails.cache.clear 来源: https://stackoverflow

Full Asset URL in a Rails .js.erb file

血红的双手。 提交于 2019-12-09 12:16:13
问题 I have a bookmarklet that can be loaded on any website. It works like this; loads http://my.example.com/assets/bookmarklet.js includes http://my.example.com/assets/bookmarklet.css The css file is added to the dom via bookmarklet.js , so it needs to know where this is. My code is as follows; // assets/javascripts/bookmarklet.js.erb var config = { stylesheetUrl: '<%= asset_path("bookmarklet.css", :only_path => false) %>' } But no matter what I try this renders as var config = { stylesheetUrl: '