【问题标题】:what do these error messages mean?这些错误信息是什么意思?
【发布时间】:2012-04-24 02:06:11
【问题描述】:

我在 hartl rails 教程的第 9 节,这个 def 没有意义。想法?

1) User pages index 
 Failure/Error: visit users_path
 ActionView::Template::Error:
   wrong number of arguments (2 for 1)
 # ./app/helpers/users_helper.rb:3:in `gravatar_for'
 # ./app/views/users/index.html.erb:7:in `block in _app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./app/views/users/index.html.erb:5:in `each'
 # ./app/views/users/index.html.erb:5:in `_app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./spec/requests/user_pages_spec.rb:12:in `block (3 levels) in <top (required)>'



2) User pages index should list each user
 Failure/Error: visit users_path
 ActionView::Template::Error:
   wrong number of arguments (2 for 1)
 # ./app/helpers/users_helper.rb:3:in `gravatar_for'
 # ./app/views/users/index.html.erb:7:in `block in _app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./app/views/users/index.html.erb:5:in `each'
 # ./app/views/users/index.html.erb:5:in `_app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./spec/requests/user_pages_spec.rb:12:in `block (3 levels) in <top (required)>'

【问题讨论】:

  • 好像你用 2 个参数调用 gravatar_for,它应该是一个。

标签: ruby-on-rails ruby ruby-on-rails-3 railstutorial.org


【解决方案1】:

Chapter 7's first exercise 指定您扩展gravatar_for 方法以包含一个新的可选参数以包含大小。你可能没有做这个练习,所以它只期望原始的 1 参数而不是两个参数。完成练习,您应该可以通过此代码。

【讨论】:

    【解决方案2】:

    在 helper 文件夹中的 user_helper.rb 文件中,您为 gravatar_for 方法传递 2 个参数而不是 1 个参数。如果你把它的代码,它会更容易解决。

    【讨论】:

      猜你喜欢
      • 2010-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多