rspec - wrong number of arguments (given 3, expected 1..2) in Rails 7.0.x, tag.div - Stack Overflow

In Rails 5.x I could define options like so:options = {class: "...", "data-unix-timesta

In Rails 5.x I could define options like so:

options = {class: "...", "data-unix-timestamp": "...", "data-toggle":"..."}
tag.div('', options)

Upgrading to Rails 7.0.8.7, this fails:

Failure/Error: tag.div('', options)
     
ArgumentError:
  wrong number of arguments (given 3, expected 1..2)

In Rails 5.x I could define options like so:

options = {class: "...", "data-unix-timestamp": "...", "data-toggle":"..."}
tag.div('', options)

Upgrading to Rails 7.0.8.7, this fails:

Failure/Error: tag.div('', options)
     
ArgumentError:
  wrong number of arguments (given 3, expected 1..2)
Share Improve this question asked 11 hours ago Eric WanchicEric Wanchic 2,0841 gold badge24 silver badges26 bronze badges 1
  • 1 There has to be something else wrong and the below is definitely not the solution. The tag helper accepts 4 arguments so the stacktrace is likely missing some details. Willing to bet you are using rails 7 with an older ruby version and there is some form of argument expansion going on that is not supported by your version of ruby. – engineersmnky Commented 10 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

Fix: options need to be explicitly specified.

options = {class: "...", "data-unix-timestamp": "...", "data-toggle":"..."}
"<div #{tag.attributes(options)} ></div>".html_safe

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743750397a4500788.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信