asset-pipeline

Enable image caching in development mode in Rails 3.1

别等时光非礼了梦想. 提交于 2019-12-22 05:54:15
问题 In Rails 3.1 development mode (when using the asset pipeline), images served out of assets/images are served up with the response header "Cache Control: must-revalidate". This means that Google Chrome (and seemingly only Chrome) will attempt to re-fetch images numerous times—even during a single page view. This has resulted in screwy issues with all manners of DOM manipulation via JavaScript. To name a few: jQuery UI Draggable sometimes features a dramatic offset from the mouse cursor Adding

How change jquery version with rails asset pipeline

痴心易碎 提交于 2019-12-22 05:33:18
问题 application.js //= require jquery //= require jquery_ujs //= require_tree . //= require active_scaffold on client <script src="/assets/jquery.js?body=1" type="text/javascript"></script> <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script> <script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script> <script src="/assets/jquery-ui-timepicker-addon.js?body=1" type="text/javascript"></script> <script src="/assets/jquery/active_scaffold.js?body=1" type="text

In Rails how to check if javascript file exists before using javascript_include_tag

眉间皱痕 提交于 2019-12-22 05:15:08
问题 In a rails 3.2 app, I would like to check for the existence of a javascript file in the asset pipeline before including the javascript_include_tag in a file. Something like: <% if javascript_file_exists? %> <%= javascript_include_tag "#{controller_name}_controller" %> <% end %> I would like to do this so that the absence of a javascript file will not result in an error. Is there a way to do this? 回答1: A more Rails way is to use a helper. This allows you to check for a coffeescript or a

Rails app on percise32 vagrant box - assets get “text file busy” error (Errno::ETXTBSY)

本小妞迷上赌 提交于 2019-12-22 04:32:39
问题 Trying to boot up a Rails app inside a Vagrant box (percise32) host machine is Windows 7. This is my Vagrantfile Vagrant.configure('2') do |config| config.vm.box = 'precise32' config.vm.box_url = 'http://files.vagrantup.com/precise32.box' config.vm.hostname = 'rails-dev-box' config.vm.synched_folder "c:\rails_text", "/home/code" config.vm.network :forwarded_port, guest: 3000, host: 3003 config.vm.provision :puppet do |puppet| puppet.manifests_path = 'puppet/manifests' puppet.module_path =

Zurb Foundation 5, modernizr not found

放肆的年华 提交于 2019-12-22 04:12:34
问题 I get this when using Foundation 5.0.2.0 in production mode. On Rails, Unicorn, NginX & Ubuntu. "NetworkError: 404 Not Found - http://mydomain.com/javascripts/vendor/modernizr.js" 回答1: Update 3/13/14 I don't have this problem on heroku with foundation-rails-5.1.1.0. Adding javascript_include_tag "vendor/modernizr" in the head works. I could remove the modernizr I copied to the vendor directory and remove the extra line in app.js I had the same problem on heroku, the app would crash because it

Rails assets - keep license comments

谁说我不能喝 提交于 2019-12-22 04:08:32
问题 How can I prevent Uglifier from removing some comments from some files? I want to have code minified and compressed but also I want the licensing comments to remain intact. 回答1: From the documentation of uglifyJS. -nc or --no-copyright — by default, uglifyjs will keep the initial comment tokens in the generated code (assumed to be copyright information etc.). If you pass this it will discard it. which is also an option of uglifier. 来源: https://stackoverflow.com/questions/8896969/rails-assets

Asset Precompilation OK, but 404 when trying to get files

a 夏天 提交于 2019-12-22 04:01:35
问题 Ok so compiling my assets is working fine but when I run: thin start -e production none of my javascript or css is loading. My browser is also cancelling the requests to get my assets. I'm not sure why this is but I suspect its because it thinks its 404'ing on them. If you look at the top image you'll see that my application.css file was compiled and stored in my assets folder but when I try to access the file, I'm getting my 404.html file. What gives!? Edit: I was asked to post my view. Here

Rails 3.1: javascripts not served correctly from vendor/assets directory?

天大地大妈咪最大 提交于 2019-12-22 01:58:36
问题 I have organized my javascript files in a couple of directories and I have found the following strange behavior. Given the following tree: + app + assets + javascripts + common + public + common + home - home.js home.js looks like this: //= require jquery //= require jquery_ujs //= require jquery-ui //= require_directory ../../jquery_plugins //= require_directory ../../common //= require_directory ../common //= require_self Now the trick lies in the jquery_plugins directory. I placed this

Working with javascript in a view in ruby on rails

自古美人都是妖i 提交于 2019-12-22 01:29:58
问题 Alright guys, I am a ruby noobie here, and I find myself in the unfortunate situation where I am moving a project over from Django to Ruby on Rails. First things first, I am setting up my application.html.erb file, and I cannot seem to get the javascript working. The images and css are coming through, but not the javascript. There are javascript files within the assets directory and within the application.html.erb file. Neither are coming through. All of my images, css, and javascripts are

Locomotivecms Assets in Production

烈酒焚心 提交于 2019-12-21 23:30:27
问题 I have asked this question in the locomotivecms google groups, but haven't gotten any useful response yet. So, trying out here. I have a feeling the issue is not just a rails issue but has something to do with how the locomotivecms engine is implemented. I installed the locomotivecms app as per the instructions here - http://doc.locomotivecms.com/guides/get-started/install-engine The app runs fine in development mode. I then precompiled the assets and started it in production mode ( bundle