2012-04-24 112 views
3

我在第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

回答

12

Chapter 7's first exercise指定您擴展gravatar_for方法包括包括數量的新的可選參數。你可能沒有做這個練習,所以它只是期待原來的一個論點而不是兩個論點。完成練習,你應該得到這個代碼通過。

1

在幫助程序文件夾中的user_helper.rb文件中,您傳遞2個參數而不是1個gravatar_for方法。如果你把代碼放在那裏解決起來會容易得多。