提问人:andresV 提问时间:9/21/2023 最后编辑:andresV 更新时间:9/22/2023 访问量:92
错误的参数数(给定 2,预期 1)on = image_tag 'home1.jpg'
wrong number of arguments (given 2, expected 1) on = image_tag 'home1.jpg'
问:
我正在将应用程序从 rails 4.2 升级到 7.0。
我已经升级了我的宝石,但是当我尝试访问 localhost 时,它会返回类似
参数数量错误(给定 2 个,预期 1 个)
在线
= image_tag 'home1.jpg'
此外,我有一个不包含图像的管理页面,但它返回相同的错误,但在线:
= stylesheet_link_tag "admin", media: "all", "data-turbolinks-track" => "reload"
这是我的实际 gemfile:
`source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 7.0.8'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 6.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 5.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.11'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'slim-rails'
gem 'bootstrap-sass', '~> 2.3.2.0'
gem 'bootstrap-will_paginate'
gem 'rails-i18n', '~> 7.0'
gem 'devise', '~> 4.9'
gem 'simple_form', '~> 5.2'
gem 'kt-paperclip', '~> 7.2'
gem 'active_type'
#gem 'nokogiri'
#gem 'premailer-rails'
gem 'sucker_punch', '~> 1.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
# gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 4.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', '~> 4.1'
end
gem 'sprockets', '~> 3.7.2'
gem 'sprockets-rails', :require => 'sprockets/railtie'
group :development do
gem 'capistrano', '~> 3.17'
gem 'rvm-capistrano', require: false
#gem 'capistrano-local-precompile', require: false
end
gem 'puma'
gem 'mysql2', group: :production`
` 跟踪:
Application Trace | Framework Trace | Full Trace
json (1.8.6) lib/json/common.rb:155:in `initialize'
json (1.8.6) lib/json/common.rb:155:in `new'
json (1.8.6) lib/json/common.rb:155:in `parse'
execjs (2.9.1) lib/execjs/external_runtime.rb:69:in `extract_result'
execjs (2.9.1) lib/execjs/external_runtime.rb:40:in `exec'
execjs (2.9.1) lib/execjs/external_runtime.rb:15:in `initialize'
execjs (2.9.1) lib/execjs/runtime.rb:68:in `new'
execjs (2.9.1) lib/execjs/runtime.rb:68:in `compile'
execjs (2.9.1) lib/execjs/module.rb:27:in `compile'
coffee-script (2.4.1) lib/coffee_script.rb:50:in `context'
coffee-script (2.4.1) lib/coffee_script.rb:78:in `compile'
sprockets (3.7.2) lib/sprockets/coffee_script_processor.rb:21:in `block in call'
sprockets (3.7.2) lib/sprockets/cache.rb:85:in `fetch'
sprockets (3.7.2) lib/sprockets/coffee_script_processor.rb:20:in `call'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.7.2) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.7.2) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.7.2) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
sprockets (3.7.2) lib/sprockets/loader.rb:44:in `load'
sprockets (3.7.2) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.7.2) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.7.2) lib/sprockets/bundle.rb:23:in `block in call'
sprockets (3.7.2) lib/sprockets/utils.rb:200:in `dfs'
sprockets (3.7.2) lib/sprockets/bundle.rb:24:in `call'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:75:in `call_processor'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:57:in `block in call_processors'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:56:in `reverse_each'
sprockets (3.7.2) lib/sprockets/processor_utils.rb:56:in `call_processors'
sprockets (3.7.2) lib/sprockets/loader.rb:134:in `load_from_unloaded'
sprockets (3.7.2) lib/sprockets/loader.rb:60:in `block in load'
sprockets (3.7.2) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
sprockets (3.7.2) lib/sprockets/loader.rb:44:in `load'
sprockets (3.7.2) lib/sprockets/cached_environment.rb:20:in `block in initialize'
sprockets (3.7.2) lib/sprockets/cached_environment.rb:47:in `load'
sprockets (3.7.2) lib/sprockets/base.rb:66:in `find_asset'
sprockets (3.7.2) lib/sprockets/base.rb:73:in `find_all_linked_assets'
sprockets (3.7.2) lib/sprockets/manifest.rb:134:in `block in find'
sprockets (3.7.2) lib/sprockets/manifest.rb:133:in `each'
sprockets (3.7.2) lib/sprockets/manifest.rb:133:in `find'
sprockets-rails (3.4.2) lib/sprockets/railtie.rb:53:in `each'
sprockets-rails (3.4.2) lib/sprockets/railtie.rb:53:in `map'
sprockets-rails (3.4.2) lib/sprockets/railtie.rb:53:in `precompiled_assets'
sprockets-rails (3.4.2) lib/sprockets/railtie.rb:38:in `asset_precompiled?'
sprockets-rails (3.4.2) lib/sprockets/railtie.rb:266:in `block (3 levels) in <class:Railtie>'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:368:in `precompiled?'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:372:in `raise_unless_precompiled_asset'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:349:in `find_debug_asset'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:230:in `block in lookup_debug_asset'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:243:in `block in resolve_asset'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:242:in `each'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:242:in `detect'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:242:in `resolve_asset'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:229:in `lookup_debug_asset'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:171:in `block in stylesheet_link_tag'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:170:in `map'
sprockets-rails (3.4.2) lib/sprockets/rails/helper.rb:170:in `stylesheet_link_tag'
app/views/layouts/admin.html.slim:7
actionview (7.0.8) lib/action_view/base.rb:244:in `public_send'
actionview (7.0.8) lib/action_view/base.rb:244:in `_run'
actionview (7.0.8) lib/action_view/template.rb:157:in `block in render'
activesupport (7.0.8) lib/active_support/notifications.rb:208:in `instrument'
actionview (7.0.8) lib/action_view/template.rb:361:in `instrument_render_template'
actionview (7.0.8) lib/action_view/template.rb:155:in `render'
actionview (7.0.8) lib/action_view/renderer/template_renderer.rb:76:in `block in render_with_layout'
activesupport (7.0.8) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.8) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.8) lib/active_support/notifications.rb:206:in `instrument'
actionview (7.0.8) lib/action_view/renderer/template_renderer.rb:74:in `render_with_layout'
actionview (7.0.8) lib/action_view/renderer/template_renderer.rb:59:in `render_template'
actionview (7.0.8) lib/action_view/renderer/template_renderer.rb:11:in `render'
actionview (7.0.8) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (7.0.8) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (7.0.8) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (7.0.8) lib/action_view/base.rb:270:in `in_rendering_context'
actionview (7.0.8) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (7.0.8) lib/action_controller/metal/streaming.rb:216:in `_render_template'
actionview (7.0.8) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (7.0.8) lib/action_controller/metal/rendering.rb:158:in `render_to_body'
actionpack (7.0.8) lib/action_controller/metal/renderers.rb:141:in `render_to_body'
actionpack (7.0.8) lib/abstract_controller/rendering.rb:27:in `render'
actionpack (7.0.8) lib/action_controller/metal/rendering.rb:139:in `render'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:22:in `block (2 levels) in render'
/usr/local/rvm/rubies/ruby-3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
activesupport (7.0.8) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:22:in `block in render'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:91:in `cleanup_view_runtime'
activerecord (7.0.8) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:21:in `render'
responders (3.1.0) lib/action_controller/responder.rb:245:in `default_render'
responders (3.1.0) lib/action_controller/responder.rb:175:in `to_html'
responders (3.1.0) lib/action_controller/responder.rb:168:in `respond'
responders (3.1.0) lib/action_controller/responder.rb:161:in `call'
responders (3.1.0) lib/action_controller/respond_with.rb:216:in `respond_with'
devise (4.9.2) app/controllers/devise/sessions_controller.rb:14:in `new'
actionpack (7.0.8) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.8) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.0.8) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.8) lib/active_support/callbacks.rb:107:in `run_callbacks'
actionpack (7.0.8) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/rescue.rb:23:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.8) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.8) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.8) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.8) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.8) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.8) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.8) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.8) lib/action_view/rendering.rb:39:in `process'
actionpack (7.0.8) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.8) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.8) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
actionpack (7.0.8) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.8) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.8) lib/action_dispatch/routing/route_set.rb:852:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.8) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.8) lib/rack/etag.rb:27:in `call'
rack (2.2.8) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.8) lib/rack/head.rb:12:in `call'
actionpack (7.0.8) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
actionpack (7.0.8) lib/action_dispatch/http/content_security_policy.rb:36:in `call'
rack (2.2.8) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.8) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/cookies.rb:704:in `call'
activerecord (7.0.8) lib/active_record/migration.rb:638:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.8) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.8) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
web-console (4.2.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.2.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.2.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.2.1) lib/web_console/middleware.rb:17:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/show_exceptions.rb:29:in `call'
railties (7.0.8) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.8) lib/rails/rack/logger.rb:25:in `block in call'
activesupport (7.0.8) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (7.0.8) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (7.0.8) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (7.0.8) lib/rails/rack/logger.rb:25:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.8) lib/rack/method_override.rb:24:in `call'
rack (2.2.8) lib/rack/runtime.rb:22:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/static.rb:23:in `call'
rack (2.2.8) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.8) lib/action_dispatch/middleware/host_authorization.rb:138:in `call'
railties (7.0.8) lib/rails/engine.rb:530:in `call'
puma (6.4.0) lib/puma/configuration.rb:272:in `call'
puma (6.4.0) lib/puma/request.rb:100:in `block in handle_request'
puma (6.4.0) lib/puma/thread_pool.rb:378:in `with_force_shutdown'
puma (6.4.0) lib/puma/request.rb:99:in `handle_request'
puma (6.4.0) lib/puma/server.rb:443:in `process_client'
puma (6.4.0) lib/puma/server.rb:241:in `block in run'
puma (6.4.0) lib/puma/thread_pool.rb:155:in `block in spawn_thread'
有什么线索为什么会这样吗?
答:
0赞
Milind
9/22/2023
#1
查看错误,我猜这是一个编译错误。也许你应该尝试再次迁移它以确保没有中断,因为升级 gem 根本不是升级到 Rails 7 的正确方法。
有一个官方的升级指南,可以像在 Rails 7 中一样以缓慢而稳定的方式做到这一点,当它进入 javascript 编译器时,情况发生了很大变化。 仅举几例——
- Webpacker 已停用
- 您需要决定如何捆绑 JS 文件 - import maps/jsbundling/shakapacker(我使用)
要深入了解,请查看此内容 - Rails 7 中的 Javascript
此外,为了准备使用 RAILS 7 SAMPLE APP,您可以创建此 repo 并开始添加自己的代码。
评论