我的Rails應用程序沒有編譯我的資產。我遵循了許多類似的問題,但沒有一個提出的解決方案適用於我。Rails沒有編譯我的資產
我在開發環境中運行。
這就是我得到:
HTML:
<script src="/assets/application.js?body=1" type="text/javascript"></script>
JS:
// 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/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require_tree ./svgweb
//= require modernizr
//= require jquery
//= require jquery_ujs
//// Loads all Bootstrap javascripts
//= require bootstrap
//= require ckeditor/init
//= require_tree .
$(document).ready(function(){
if($('#content').children('svg').size() > 0){
$('#content').css('overflow', 'scroll');
console.log($('svg'));
}
});
這是我application.rb中
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(*Rails.groups(assets: %w(development test)))
end
module Autumnlan
class Application < Rails::Application
config.encoding = "utf-8"
config.active_record.whitelist_attributes = false
config.assets.enabled = true
config.assets.version = '1.0'
end
end
這是我development.rb
Autumnlan::Application.configure do
config.cache_classes = false
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.action_dispatch.best_standards_support = :builtin
config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.assets.compress = false
config.assets.debug = true
config.assets.compile = true
end
這是我的Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'kaminari'
gem 'rails_admin'
gem "switch_user"
#gem 'bootstrap-wysihtml5-rails'
gem "ckeditor", "3.7.1"
gem 'squeel'
gem 'bootstrap-sass'
gem 'modernizr-rails'
gem 'quiet_assets'
gem 'thin'
gem 'state_machine'
gem 'rb-readline'
gem 'compass-rails'
這些都是我安裝寶石:
bundle show
Gems included by the bundle:
* actionmailer (3.2.3)
* actionpack (3.2.3)
* activemodel (3.2.3)
* activerecord (3.2.3)
* activeresource (3.2.3)
* activesupport (3.2.3)
* arel (3.0.2)
* bbenezech-nested_form (0.0.6)
* bcrypt-ruby (3.0.1)
* bootstrap-sass (2.0.4.0)
* builder (3.0.0)
* bundler (1.3.5)
* chunky_png (1.2.6)
* ckeditor (3.7.1)
* coffee-rails (3.2.2)
* coffee-script (2.2.0)
* coffee-script-source (1.3.3)
* compass (0.12.2)
* compass-rails (1.0.3)
* daemons (1.1.9)
* devise (2.1.2)
* erubis (2.7.0)
* eventmachine (0.12.10)
* execjs (1.4.0)
* fssm (0.2.9)
* haml (3.1.7)
* hike (1.2.1)
* hpricot (0.8.6)
* i18n (0.6.0)
* journey (1.0.4)
* jquery-rails (2.1.1)
* jquery-ui-rails (1.1.1)
* json (1.7.5)
* kaminari (0.13.0)
* mail (2.4.4)
* mime-types (1.19)
* modernizr-rails (2.0.6)
* multi_json (1.3.6)
* orm_adapter (0.4.0)
* pg (0.14.0)
* polyamorous (0.5.0)
* polyglot (0.3.3)
* quiet_assets (1.0.1)
* rack (1.4.1)
* rack-cache (1.2)
* rack-pjax (0.5.9)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.3)
* rails_admin (0.0.5)
* railties (3.2.3)
* rake (0.9.2.2)
* rb-readline (0.4.2)
* rdoc (3.12)
* remotipart (1.0.2)
* sass (3.2.1)
* sass-rails (3.2.5)
* sprockets (2.1.3)
* squeel (1.0.9)
* state_machine (1.1.2)
* switch_user (0.8.0)
* thin (1.4.1)
* thor (0.14.6)
* tilt (1.3.3)
* treetop (1.4.10)
* tzinfo (0.3.33)
* uglifier (1.2.7)
* warden (1.2.1)
這是我紅寶石環境:
rvm info
[email protected]:
system:
uname: "Linux spugna 3.8.0-29-generiC#42~precise1-Ubuntu SMP Wed Aug 14 15:31:16 UTC 2013 i686 i686 i386 GNU/Linux"
system: "ubuntu/12.04/i386"
bash: "/bin/bash => GNU bash, versione 4.2.25(1)-release (i686-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.22.14() by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]"
updated: "2 days 21 hours 38 minutes 19 seconds ago"
path: "/home/spugna/.rvm"
ruby:
interpreter: "ruby"
version: "2.0.0p247"
date: "2013-06-27"
platform: "i686-linux"
patchlevel: "2013-06-27 revision 41674"
full_version: "ruby 2.0.0p247 (2013-06-27 revision 41674) [i686-linux]"
homes:
gem: "/home/spugna/.rvm/gems/[email protected]"
ruby: "/home/spugna/.rvm/rubies/ruby-2.0.0-p247"
binaries:
ruby: "/home/spugna/.rvm/rubies/ruby-2.0.0-p247/bin/ruby"
irb: "/home/spugna/.rvm/rubies/ruby-2.0.0-p247/bin/irb"
gem: "/home/spugna/.rvm/rubies/ruby-2.0.0-p247/bin/gem"
rake: "/home/spugna/.rvm/gems/[email protected]/bin/rake"
environment:
PATH: "/home/spugna/.rvm/gems/[email protected]/bin:/home/spugna/.rvm/gems/[email protected]/bin:/home/spugna/.rvm/rubies/ruby-2.0.0-p247/bin:/home/spugna/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
GEM_HOME: "/home/spugna/.rvm/gems/[email protected]"
GEM_PATH: "/home/spugna/.rvm/gems/ruby-2.0.0[email protected]:/home/spugna/.rvm/gems/[email protected]"
MY_RUBY_HOME: "/home/spugna/.rvm/rubies/ruby-2.0.0-p247"
IRBRC: "/home/spugna/.rvm/rubies/ruby-2.0.0-p247/.irbrc"
RUBYOPT: ""
gemset: "autumnlan"
什麼命令你想運行? '耙資產:預編譯'?並在哪個環境? – weltschmerz
開發環境。它發生在'隨時編譯'和'rake資產預編譯' –
試試看[這個](http://stackoverflow.com/questions/10081832/how-do-i-precompile-assets-in-rails-在開發環境中)並讓我知道它是否有幫助。 – weltschmerz