3

我在 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)>'
4

2 回答 2

12

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

于 2012-04-24T02:15:07.297 回答
1

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

于 2012-04-24T05:31:12.483 回答