asset-pipeline

“ActionView::Template::Error ( isn't precompiled)” raised on “image_tag nil”

主宰稳场 提交于 2019-12-18 21:54:35
问题 If I don't handle view correctly, Production environment show 500. <%= image_tag post.user.image_url %> This could be <%= image_tag post.user.image_url if post.user && post.user.image_url %> but I am little careless and forgot this issue several times. How can I prevent this? How can I use <%= image_tag nil %> in production environment without raising 500? 回答1: image_tag must have a source, Rails can do nothing with it, but raise an exception. You can write a helper like this: module

“ActionView::Template::Error ( isn't precompiled)” raised on “image_tag nil”

一世执手 提交于 2019-12-18 21:53:59
问题 If I don't handle view correctly, Production environment show 500. <%= image_tag post.user.image_url %> This could be <%= image_tag post.user.image_url if post.user && post.user.image_url %> but I am little careless and forgot this issue several times. How can I prevent this? How can I use <%= image_tag nil %> in production environment without raising 500? 回答1: image_tag must have a source, Rails can do nothing with it, but raise an exception. You can write a helper like this: module

sass error in rails app on heroku: can't dump anonymous class

喜你入骨 提交于 2019-12-18 19:06:38
问题 I'm getting the following warnings from heroku after trying to enable source maps for chrome http://blog.vhyza.eu/blog/2013/09/22/debugging-rails-4-coffeescript-and-sass-source-files-in-google-chrome/ What do they indicate and what, if anything, should I change? My gemfile: source 'https://rubygems.org' ruby '2.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.0' # Use sqlite3 as the database for Active Record #gem 'sqlite3' gem 'pg' gem 'devise' gem 'font

Is there a way to add an exception to the require_tree in a manifest file?

假装没事ソ 提交于 2019-12-18 14:14:37
问题 Is there a way you can include all files in a directory except one, or all directories except one? So something like: require_tree . :except 'this_one' Just wondering and can't figure out where the documentation is on the "require_tree" method in the manifest file. 回答1: Depending on the version of your environment the following may be possible: //= require_tree "." exclude: "file1", "file2" See this SO thread: Rails 3.1 Sprockets require directives - is there a way to exclude particular files

files produced by asset:precompile don't match urls generated by stylesheet_link_tag (missing digest) in minimal rails 4 site

删除回忆录丶 提交于 2019-12-18 13:01:33
问题 I'm using Ruby 2.0.0-p247 and Rails 4.0.0 If I make a minimal Rails 4 site like this: rails new minimal cd minimal rails generate controller home index tee config/routes.rb <<EOF Minimal::Application.routes.draw do root 'home#index' end EOF Then precompile the assets with rake assets:precompile It generates assets like: I, [2013-09-04T17:05:36.992951 #3549] INFO -- : Writing /WORKINGDIR/minimal/public/assets/application-723d1be6cc741a3aabb1cec24276d681.js I, [2013-09-04T17:05:37.052303 #3549]

Asset compiling crashing on server environment with: “NoMethodError: undefined method `[]' for nil:NilClass”

ⅰ亾dé卋堺 提交于 2019-12-18 12:13:08
问题 I've been pulling my hair out for this one. I've always had a bad relationship with the asset-pipeline, it is always giving me trouble.. And today again.. When I try and compile my assets locally, everything is fine: $ RAILS_ENV=production rake assets:precompile --trace But when I deploy with Capistrano which does: cd /var/www/xxx/releases/20140717164232 && ( RAILS_ENV=production bundle exec rake assets:precompile ) It crashes with the following error: rake aborted! NoMethodError: undefined

Compressing rails assets and nginx gzip

南笙酒味 提交于 2019-12-18 11:55:35
问题 Do I have to configure nginx to compress assets (gzip set to on) if I have compressed rails assets with rake assets:precompile ? I mean does it make sense or not? Will performance better or worse? Thank you! 回答1: No, you do not. They are not the same kind of compression. When you run rake assets:precompile , all you're really doing is joining a bunch of files into one file and dumping it to the disk. Actually, according to the official documentation, it is two files: When files are

Rails 3.1: Determine if asset exists

岁酱吖の 提交于 2019-12-18 10:32:23
问题 Is there a built-in way to determine if an asset exists without resorting to File.exists?(File.join(Rails.root, "foo", "bar", "baz")) and that looks through the asset paths. My app goes and fetches images from a remote server on a Resque queue; until we have the image downloaded I want to serve a placeholder image. Currently I'm using File.exists ... but this means hard-coding a path, which sucks, or looking through the configured asset paths. It seems like this should be there already, but I

uglifier not working in rails

荒凉一梦 提交于 2019-12-18 04:14:09
问题 config/application.rb ... # Enable the asset pipeline config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' config.assets.digest = true config.assets.paths << "#{Rails.root}/vendor/assets/images" ... config/environment.rb ... ENV['RAILS_ENV'] ||= 'production' ... My gemfile ... gem 'uglifier' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', "

Rails I18n of CSS file

大城市里の小女人 提交于 2019-12-18 03:42:12
问题 I am trying to internationalize my site, and one thing is to use different font-size for different languages. Also some text-images need to be replaced as well. I think the only way to do this is to have additional locale-specific CSS files in the public folder and load them based on locale in my view. This avoids asset pipeline from compiling those specific CSS files. But I am wonderiing if there a better way to do this? 回答1: Your best bet in organization is to have different style sheets