1

我正在运行:ruby 1.9.3p392 (2013-02-22) [i386-mingw32] compass-rails 1.0.3

我使用 Windows RailsInstaller 安装 Ruby on Rails

宝石文件

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'compass-rails','~> 1.0.2'
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

我目前在导入精灵时遇到问题。我的精灵在:assets/images/source

在我的 _shared.scss 文件中,我有://Sprites

@import "./source/*.png";
$source-sprite-dimensions: true;

在我的 application.scss 我有:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 */

@import "_shared.scss";
@import "baseline.scss";
@import "global.scss";
@import "normalize.scss";
@import "print.scss";
@import "desktop.scss";
@import "tablet.scss";
@import "home.css.scss";

我也在使用 Rails 服务器,而不是指南针观察者。但是,当我浏览到 localhost:3000/assets/application.css 的页面时,我收到以下错误:

  body:before {
    font-weight: bold;
    content: "\000a TypeError: can't convert nil into String\000a   (in c:\002f RangerRomOnRails\002f RangerRom\002f app\002f assets\002f stylesheets\002f desktop.scss)";
  }

  body:after {
    content: "\000a   C:\002f RailsInstaller\002f Ruby1.9.3\002f lib\002f ruby\002f gems\002f 1.9.1\002f gems\002f compass-0.12.2\002f lib\002f compass\002f sass_extensions\002f functions\002f image_size.rb:17:in `extname'";
  }

这是完整的堆栈跟踪: compass (0

.12.2) lib/compass/sass_extensions/functions/image_size.rb:17:in `extname'
    compass (0.12.2) lib/compass/sass_extensions/functions/image_size.rb:17:in `initialize'
    compass (0.12.2) lib/compass/sass_extensions/functions/image_size.rb:50:in `new'
    compass (0.12.2) lib/compass/sass_extensions/functions/image_size.rb:50:in `image_dimensions'
    compass (0.12.2) lib/compass/sass_extensions/functions/image_size.rb:4:in `image_width'
    sass (3.2.9) lib/sass/script/funcall.rb:112:in `_perform'
    sass (3.2.9) lib/sass/script/node.rb:40:in `perform'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:298:in `visit_prop'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:100:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `map'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:121:in `with_environment'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:108:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `block in visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:100:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `map'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:121:in `with_environment'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:108:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `block in visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:100:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `map'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:121:in `with_environment'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:108:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `block in visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:362:in `visit_media'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:100:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `map'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:53:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:121:in `with_environment'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:108:in `visit_children'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `block in visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:128:in `visit_root'
    sass (3.2.9) lib/sass/tree/visitors/base.rb:37:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:100:in `visit'
    sass (3.2.9) lib/sass/tree/visitors/perform.rb:7:in `visit'
    sass (3.2.9) lib/sass/tree/root_node.rb:20:in `render'
    sass (3.2.9) lib/sass/engine.rb:315:in `_render'
    sass (3.2.9) lib/sass/engine.rb:262:in `render'
    sass-rails (3.2.6) lib/sass/rails/template_handlers.rb:106:in `evaluate'
    tilt (1.4.1) lib/tilt/template.rb:103:in `render'
    sprockets (2.2.2) lib/sprockets/context.rb:193:in `block in evaluate'
    sprockets (2.2.2) lib/sprockets/context.rb:190:in `each'
    sprockets (2.2.2) lib/sprockets/context.rb:190:in `evaluate'
    sprockets (2.2.2) lib/sprockets/processed_asset.rb:12:in `initialize'
    sprockets (2.2.2) lib/sprockets/base.rb:249:in `new'
    sprockets (2.2.2) lib/sprockets/base.rb:249:in `block in build_asset'
    sprockets (2.2.2) lib/sprockets/base.rb:270:in `circular_call_protection'
    sprockets (2.2.2) lib/sprockets/base.rb:248:in `build_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:93:in `block in build_asset'
    sprockets (2.2.2) lib/sprockets/caching.rb:19:in `cache_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:92:in `build_asset'
    sprockets (2.2.2) lib/sprockets/base.rb:169:in `find_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:60:in `find_asset'
    sprockets (2.2.2) lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
    sprockets (2.2.2) lib/sprockets/processed_asset.rb:105:in `each'
    sprockets (2.2.2) lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
    sprockets (2.2.2) lib/sprockets/processed_asset.rb:97:in `build_required_assets'
    sprockets (2.2.2) lib/sprockets/processed_asset.rb:16:in `initialize'
    sprockets (2.2.2) lib/sprockets/base.rb:249:in `new'
    sprockets (2.2.2) lib/sprockets/base.rb:249:in `block in build_asset'
    sprockets (2.2.2) lib/sprockets/base.rb:270:in `circular_call_protection'
    sprockets (2.2.2) lib/sprockets/base.rb:248:in `build_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:93:in `block in build_asset'
    sprockets (2.2.2) lib/sprockets/caching.rb:19:in `cache_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:92:in `build_asset'
    sprockets (2.2.2) lib/sprockets/base.rb:169:in `find_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:60:in `find_asset'
    sprockets (2.2.2) lib/sprockets/bundled_asset.rb:38:in `init_with'
    sprockets (2.2.2) lib/sprockets/asset.rb:24:in `from_hash'
    sprockets (2.2.2) lib/sprockets/caching.rb:15:in `cache_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:92:in `build_asset'
    sprockets (2.2.2) lib/sprockets/base.rb:169:in `find_asset'
    sprockets (2.2.2) lib/sprockets/index.rb:60:in `find_asset'
    sprockets (2.2.2) lib/sprockets/environment.rb:78:in `find_asset'
    sprockets (2.2.2) lib/sprockets/base.rb:177:in `[]'
    actionpack (3.2.13) lib/sprockets/helpers/rails_helper.rb:126:in `asset_for'
    actionpack (3.2.13) lib/sprockets/helpers/rails_helper.rb:44:in `block in stylesheet_link_tag'
    actionpack (3.2.13) lib/sprockets/helpers/rails_helper.rb:43:in `collect'
    actionpack (3.2.13) lib/sprockets/helpers/rails_helper.rb:43:in `stylesheet_link_tag'
    app/views/layouts/application.html.erb:16:in `_app_views_layouts_application_html_erb___824639613_33845076'
    actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
    activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
    actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
    actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
    actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
    actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
    actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
    actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
    actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
    actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
    actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
    actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
    actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
    actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
    actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
    actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
    activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
    activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
    actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
    actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
    activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
    actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
    actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
    actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
    actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
    actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
    actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    activesupport (3.2.13) lib/active_support/callbacks.rb:414:in `_run__956028316__process_action__416811168__callbacks'
    activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
    activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
    activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
    actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
    actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
    actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
    activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
    actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
    activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
    actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
    actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
    actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
    actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
    journey (1.0.4) lib/journey/router.rb:68:in `block in call'
    journey (1.0.4) lib/journey/router.rb:56:in `each'
    journey (1.0.4) lib/journey/router.rb:56:in `call'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
    rack (1.4.5) lib/rack/etag.rb:23:in `call'
    rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
    rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
    rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
    activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
    activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
    activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__360878605__call__248365880__callbacks'
    activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
    activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
    activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
    actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
    railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
    railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
    activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
    railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
    rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
    rack (1.4.5) lib/rack/runtime.rb:17:in `call'
    activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
    rack (1.4.5) lib/rack/lock.rb:15:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
    railties (3.2.13) lib/rails/engine.rb:479:in `call'
    railties (3.2.13) lib/rails/application.rb:223:in `call'
    rack (1.4.5) lib/rack/content_length.rb:14:in `call'
    railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
    rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
4

1 回答 1

1

I got the same error and this PivotalLabs post helped me resolve it. It's just that they don't mention the error in the post.

In other words, do both config.compass.generated_images_dir and config.assets.paths << Rails.root.join('public', 'sprites').

Good luck!

于 2013-11-27T08:40:09.300 回答