我在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)>'
答案 0 :(得分:12)
Chapter 7's first exercise指定您扩展gravatar_for
方法以包含用于包含大小的新的可选参数。你可能没有做这个练习,所以它只期望原始的1个参数而不是两个参数。完成练习后,您应该通过此代码。
答案 1 :(得分:1)
在helper文件夹中的user_helper.rb文件中,为 gravatar_for 方法传递2个参数而不是1。如果你把它的代码放在一起会更容易解决。