这些错误信息是什么意思?

问题描述:

我在第9节的hartl rails教程中,这个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)>' 
+3

好像你正在用2个参数调用'gravatar_for',它应该是一个。 – Robin 2012-04-24 02:08:03

Chapter 7's first exercise指定您扩展gravatar_for方法包括包括数量的新的可选参数。你可能没有做这个练习,所以它只是期待原来的一个论点而不是两个论点。完成练习,你应该得到这个代码通过。

在帮助程序文件夹中的user_helper.rb文件中,您传递2个参数而不是1个gravatar_for方法。如果你把代码放在那里解决起来会容易得多。