asset-pipeline

Rails javascript only works after reload

限于喜欢 提交于 2019-12-17 03:58:08
问题 The problem is exactly what the heading says. The javaScript is in the asset pipeline i.e assets/javascripts/myfile.js.coffee In the application.js I have: //= require jquery //= require jquery_ujs //= require turbolinks //= require jquery.ui.all //= requier twitter/bootstrap //= require jasny-bootstrap //= require_tree . This is the coffeescript $(document).ready -> $("#close").click -> $(this).parent().parent().slideUp("slow") $( "#datepicker" ).datepicker dateFormat : "yy-mm-dd" player

How to optimize the asset compilation rake task in Rails 3.1 while deploying eating up the all memory?

此生再无相见时 提交于 2019-12-14 04:11:37
问题 The production box is of 768MB node at Linode. When I am deploying a Rails 3.1 app, the asset compilation takes place which invokes other 2 rake tasks with the Rails app env loaded. So, one task is occupying 30% of the memory which makes the 3 tasks to 90% of the memory and the capistrano command dies with zlib(finalizer): the stream was freed prematurely. error. Its getting me frustrated since it has already ate my whole day!! 回答1: This is know rails issue. You can find one solution here 来源:

Link directly to compiled resource in asset pipeline?

泪湿孤枕 提交于 2019-12-14 04:00:43
问题 I have a script that's basically a "widget" that users embed. It's got just simple vanilla javascript and doesn't have any require's to other resources. It's located at /app/assets/javascripts/delivery.js What I want to do is have the file get compressed/compiled and then let users link directly to it from a script tag, ie. <script src="http://example.com/assets/delivery.js"></script> But right now...that's a no-go. That file doesn't exist in production. So, how can I compress that file like

Should Rails uglifier uglify (mangle) function names?

不羁的心 提交于 2019-12-14 03:47:38
问题 My .js files are compressed and variables mangled, but function names are not mangled (running latest Rails 3.2.8 and latest uglify 1.3.0 gem) on Heroku. According to https://github.com/lautis/uglifier#usage the "mangle" option defaults to true. Below is my config. From production.rb: config.assets.compress = true config.assets.js_compressor = :uglifier I've also tried config.assets.compress = true config.assets.js_compressor = Uglifier.new(:mangle => true, :toplevel => true, :copyright =>

$ is not defined within a .js.erb view using Webpack 2 in Rails app

浪子不回头ぞ 提交于 2019-12-14 03:46:02
问题 I'm migrating from assets pipeline to Webpack 2 in a Rails 4 app. Everything seems to work fine, except for the JS code using jQuery within a .js.erb view. The content of the webpack.config.js is as follows (omitted code for fingerprinting and compression): const path = require('path') const webpack = require('webpack') const ExtractTextPlugin = require('extract-text-webpack-plugin') const jsOutputTemplate = 'javascripts/[name].js' const cssOutputTemplate = 'stylesheets/[name].css' module

How to avoid precompiling in Rails >= 3.1 asset pipeline when changing application.js

一个人想着一个人 提交于 2019-12-14 03:42:48
问题 I precompiled my files in the asset pipeline after upgrading to rails 3.1 (and later to 3.2) Now (working in development mode) I have to recompile them after every change to see them appear. As this takes about one minute, development is nearly impossible. I have made the following relevant entries in config/development.rb config.cache_classes = false # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Do

javascript - Twitter bootstrap jquery plugins not compiled for production

送分小仙女□ 提交于 2019-12-14 03:41:18
问题 I'm developing a 3.1 Rails app with Twitter Bootstrap using seyhunak's gem. On the production mode, I was able to use basic bootstrap CSS and JS through pipeline precompilation: RAILS_ENV=production bundle exec rake assets:precompile Using the gem file : group :assets do gem 'sass-rails', '~> 3.1.5' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' gem "twitter-bootstrap-rails" end And the application.js file: //= require_tree . //= require jquery //= require jquery_ujs //= require

Rails 3.1 404 Error when loading .css files that are present in public/assets

橙三吉。 提交于 2019-12-13 21:35:00
问题 I've got an application I've been running in development for a long time, and recently switched to running it in production to better test things out. Assets are no longer loading, so the entire look of the application is wrecked. I see errors like this in console: cache: [GET /assets/login-b5cc6c1d02b7c2fe3fd9e365a0d6ff82.css] miss cache: [GET /assets/main-9f54f3726daba54b6104bfa715be64d7.css] miss If I go ahead and login: cache: [GET /] miss ---------------------- authorize user -----------

rails assets not being compiled into one file?

不想你离开。 提交于 2019-12-13 17:42:20
问题 My application.js file: //= require jquery //= require jquery_ujs //= require_tree ./includes //= require global My layout file: <!DOCTYPE html> <html> <head> <title>Spectrum</title> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> </head> ... My config/environments/development.rb file: # Expands the lines which load the assets config.assets.debug = false However, when I load the page in a browser, all the js and css files are still

Use Rails 3.1 Asset Paths in a SCSS Partial

假如想象 提交于 2019-12-13 14:41:03
问题 I have the following setup: app/assets/stylesheets/application.css.scss /* *= require_self *= require fancybox */ /* COLORS.. */ /* MIXINS... */ /* FONT STACKS... */ /* IMPORTS */ @import "reset"; @import "supergrid"; @import "rails"; @import "app"; @import "forms"; @import "layout"; In my various partials I'm having a real problem with the asset paths. When inside application.css.scss or anything loaded by the manifest, I can use: .example { background-image: image-path("background.png"); }