我最近升级了一个项目到ruby 3.2.2
和rails 6.1
我遇到了ActionView::Base
的问题。在最近的升级中,我需要向ActionView::Base.new
传递3个参数,而不是2个。根据文档,ActionView
现在接收lookup_context, assigns, controller
view = ActionView::Base.new(
ActionController::Base.view_paths,
{
client: client,
report: self.report,
},
nil
)
所以我通过传递nil
(如上所示)修复了它,但现在我得到了一个不同的错误:
/usr/local/rvm/gems/ruby-3.2.2/gems/actionview-6.1.7.3/lib/action_view/base.rb:264:in `in_rendering_context': undefined method `html_fallback_for_js' for #<ActionView::PathSet:0x0000000110898f58 @paths=[#<ActionView::OptimizedFileSystemResolver:0x000000010fa92670 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000000110898f30 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x0000000110898eb8>, @cache=#<ActionView::Resolver::Cache:0x0000000110898e90 keys=0 queries=0>, @path="/Users/Mari/reporting/app/views">, #<ActionView::OptimizedFileSystemResolver:0x000000010fa92760 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x00000001108994a8 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x0000000110899408>, @cache=#<ActionView::Resolver::Cache:0x00000001108993e0 keys=0 queries=0>, @path="/usr/local/rvm/gems/ruby-3.2.2/gems/graphiql-rails-1.9.0/app/views">, #<ActionView::OptimizedFileSystemResolver:0x000000010fa92850 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000000110899ac0 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x0000000110899a48>, @cache=#<ActionView::Resolver::Cache:0x0000000110899a20 keys=0 queries=0>, @path="/usr/local/rvm/gems/ruby-3.2.2/gems/teaspoon-1.2.2/app/views">, #<ActionView::OptimizedFileSystemResolver:0x000000010fa92940 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000000110899e80 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x0000000110899e08>, @cache=#<ActionView::Resolver::Cache:0x0000000110899de0 keys=0 queries=0>, @path="/usr/local/rvm/gems/ruby-3.2.2/gems/devise-security-0.18.0/app/views">, #<ActionView::OptimizedFileSystemResolver:0x000000010fa92990 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x000000011089a268 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x000000011089a1f0>, @cache=#<ActionView::Resolver::Cache:0x000000011089a1c8 keys=0 queries=0>, @path="/usr/local/rvm/gems/ruby-3.2.2/gems/devise-4.8.0/app/views">, #<ActionView::OptimizedFileSystemResolver:0x000000010fa929e0 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x000000011089a740 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x000000011089a6c8>, @cache=#<ActionView::Resolver::Cache:0x000000011089a650 keys=0 queries=0>, @path="/usr/local/rvm/gems/ruby-3.2.2/gems/ckeditor-4.3.0/app/views">]> (NoMethodError)
if !lookup_context.html_fallback_for_js && options[:formats]
actionview
版本为6.1.7.3
2条答案
按热度按时间uubf1zoe1#
在Rails 6.1中,
ActionView::Base.new
有3个参数:lookup_context,分配,控制器但是你传递了
ActionView::PathSet
示例而不是ActionView::LookupContext
这个对象没有这样的getter,这就是为什么你有错误
而不是将此 Package 路径设置到查找上下文中。另外,在新的Ruby中,如果名称等于键值,则不需要重复的值
之后,您可以使用此视图进行渲染
00jrzges2#
从this answer
我已将呼叫从
ActionView::Base.new
更改为ActionView::Base.with_empty_template_cache.new
也是从上下文到
LookupContext
的参数之一,如下所示:从ActionController::Base.view_paths
到ActionView::LookupContext.new(ActionController::Base.view_paths)
调用现在看起来像这样: