我刚刚被分配到一个rails 3.2.13
项目,而我本地环境的某些东西根本不喜欢该应用程序,即使它在其他人的计算机上运行正常。我也是应用程序的新手,所以不太熟悉结构,这让它更令人沮丧。目前的问题是每当我启动服务器并转到本地主机时,我都会
undefined method `empty?' for nil:NilClass
(in /Users/app/assets/stylesheets/application.less)
该错误表示_head部分中存在引用application.less
的问题<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><%= content_for?(:title) ? yield(:title) : "Travel" %></title>
<meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Travel" %>">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "dashboard", :media => "all" %>
<%= stylesheet_link_tag "common", :media => "all" %>
<%= stylesheet_link_tag "jquery-ui-1.10.4.custom.min", :media => "all" %>
<%= stylesheet_link_tag "datetimepicker", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "jquery-ui-1.10.4.custom.min" %>
<%= csrf_meta_tags %>
<%= yield(:head) %>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,300italic' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<link href="assets/css/ie.css" rel='stylesheet' type='text/css'>
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css">
<![endif]-->
</head>
如果我将以下几行删除,应用程序会渲染,但没有任何样式有意义。
<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "dashboard", :media => "all" %>
<%= stylesheet_link_tag "common", :media => "all" %>
<%= stylesheet_link_tag "jquery-ui-1.10.4.custom.min", :media => "all" %>
<%= stylesheet_link_tag "datetimepicker", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "jquery-ui-1.10.4.custom.min" %>
没有空? application.less
中的方法或其所指的任何内容,据我所知。
/*
* 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.
*
*/
@import "twitter/bootstrap/bootstrap";
@import "font-awesome";
//Argo variables & Custom style
@import "argo/variables.less";
@import "argo/custom-scrollbar.less";
@import "argo/argo.less";
@import "argo/button.less";
@import "social-buttons.less";
@import "responsive.less";
@import "style.less"; // style.less should be the last to load in order to be able to overwrite default properties.
// Seems this doesn't work on production !! Try inport it inside the <head> view.
// @import "dashboard";
// @import "datetimepicker.css";
的Gemfile
source "https://rubygems.org"
gem "rails", "3.2.13"
gem "pg"
gem "nokogiri"
group :assets do
gem "sass", "3.1.10"
gem "sass-rails"
gem "less-rails"
gem "coffee-rails", "~> 3.2.1"
gem "uglifier", ">= 1.0.3"
gem "quiet_assets"
end
gem "jquery-rails", "2.3.0"
gem "docx_templater"
gem 'haml', '3.1.7'
gem 'geocoder'
gem "less-rails-bootstrap", "~> 2.3.2"
gem "less-rails-fontawesome", "~> 0.4.3"
gem "therubyracer"
gem "devise", ">= 2.2.3"
gem "omniauth"
gem "omniauth-facebook", "1.4.0"
gem "cancan", ">= 1.6.9"
gem "rolify", ">= 3.2.0"
gem "figaro", ">= 0.6.3"
gem "filepicker-rails"
gem "activeadmin"
gem "just-time-picker"
gem "meta_search", ">= 1.1.0.pre"
gem "country-select"
gem "ckeditor"
#gem "roadie"
gem "momentjs-rails" # http://momentjs.com
旁注,我认为可能存在更大的问题,因为我必须注释掉一些东西才能到达这里。因为我将rails 4.1
用于我的其他应用程序,是否有自制软件或某些本地配置的东西会搞乱?我应该重新卸载并重新安装所有内容吗?
完整的错误痕迹
sass (3.1.10) lib/sass/tree/root_node.rb:23:in `render'
sass (3.1.10) lib/sass/engine.rb:300:in `_render'
sass (3.1.10) lib/sass/engine.rb:247:in `render'
sass-rails (3.2.6) lib/sass/rails/compressor.rb:16:in `compress'
actionpack (3.2.13) lib/sprockets/compressors.rb:74:in `compress'
sprockets (2.2.2) lib/sprockets/processing.rb:243:in `block in css_compressor='
sprockets (2.2.2) lib/sprockets/processor.rb:29:in `call'
sprockets (2.2.2) lib/sprockets/processor.rb:29: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/bundled_asset.rb:26:in `initialize'
sprockets (2.2.2) lib/sprockets/base.rb:252:in `new'
sprockets (2.2.2) lib/sprockets/base.rb:252: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/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/_head.html.erb:7:in `_app_views_layouts__head_html_erb___1065452930202511865_70305601381520'
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/partial_renderer.rb:265:in `render_partial'
actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
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_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:237:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:41:in `render_partial'
actionpack (3.2.13) lib/action_view/helpers/rendering_helper.rb:27:in `render'
haml (3.1.7) lib/haml/helpers/action_view_mods.rb:13:in `render_with_haml'
app/views/layouts/application.html.erb:11:in `_app_views_layouts_application_html_erb___277714497504725548_70305601320420'
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'
/Users/MontyHackintosh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/benchmark.rb:296: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/responder.rb:232:in `default_render'
actionpack (3.2.13) lib/action_controller/metal/responder.rb:160:in `to_html'
actionpack (3.2.13) lib/action_controller/metal/responder.rb:153:in `respond'
actionpack (3.2.13) lib/action_controller/metal/responder.rb:146:in `call'
actionpack (3.2.13) lib/action_controller/metal/mime_responds.rb:239:in `respond_with'
devise (3.2.4) app/controllers/devise/sessions_controller.rb:10:in `new'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4: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:447:in `_run__4105908760234858153__process_action__1733817669043599896__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'
actionpack (3.2.13) lib/action_dispatch/routing/mapper.rb:42: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'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
sass (3.1.10) lib/sass/plugin/rack.rb:54:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34: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__2732989691270559818__call__1934934084652397979__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'
quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets'
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'
/Users/MontyHackintosh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/MontyHackintosh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/MontyHackintosh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
更新:
有人指出,设计和路线可能存在问题。事实上,我必须注释scope "/:locale", :constraints => {:locale => /[a-z]{2}(-[A-Z]{2})?/} do
下面的行,以便服务器甚至可以启动。如果我取消注释此行,服务器将无法启动,它显示为:
`devise_omniauth_callback': Devise does not support scoping omniauth callbacks under a dynamic segment (RuntimeError)
and you have set "/:locale/users". You can work around by passing
`skip: :omniauth_callbacks` and manually defining the routes. Here is an example:
match "/users/auth/:provider",
constraints: { provider: /google|facebook/ },
to: "devise/omniauth_callbacks#passthru",
as: :omniauth_authorize,
via: [:get, :post]
match "/users/auth/:action/callback",
constraints: { action: /google|facebook/ },
to: "devise/omniauth_callbacks",
as: :omniauth_callback,
via: [:get, :post]
的routes.rb
scope "/:locale", :constraints => {:locale => /[a-z]{2}(-[A-Z]{2})?/} do
root to: "dashboards#index"
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", :registrations => "users/registrations" }
resources :dashboards
resources :users do
resources :travels do
get 'cgv', :on => :member
end
resources :cars
resources :rents do
resource :payment
get 'cgv', :on => :member
end
end
resources :rents, only: [:new]
match "/rents/check_discount" => "rents#check_discount", as: "check_discount"
match "/rents/autocomplete_user" => "rents#autocomplete_user", as: "autocomplete_user"
match "/rents/fill_driver_infos" => "rents#fill_driver_infos", as: "fill_driver_infos"
resources :travels, only: [:new]
authenticated :user do
match "/travels", to: redirect { |p, req| "/#{p[:locale]}/users/#{req.env["warden"].user(:user).id}/travels/new" }, :as => 'travels'
end
unauthenticated :user do
match '/travels(/:action)' => 'anonymous_travels', :as => 'travels'
end
match '/search(/:action)' => 'search', :as => 'search'
end
答案 0 :(得分:1)
我怀疑你有宝石版本的不一致......你应该将你的Gemfile.lock与同事的Gemfile.lock进行比较。
如果您已完成捆绑更新,则可能是问题的原因。它是一个有用的工具,但需要“极其谨慎”。
http://ryanbigg.com/2011/01/why-you-should-run-bundle-update/
干杯 史蒂夫