2014-09-24 66 views
0

我讀過這個線程helper方法:Rails optional argument,並試圖實現它在Rails 4助手功能,看起來像這樣:軌道所需的參數

# this is in the application helper 
def getRank(team_id, week = '') 
    if week.empty? 
    week = Settings.pluck(:week) # grab the current week 
    end 
    # do some stuff to get the current team's rank 
end 

當我把這個控制檯,但是我仍然得到:

> helper.getRank(5) 
ArgumentError: wrong number of arguments (1 for 2) 
from /home/rails_testing/app/helpers/application_helper.rb:24:in `getRank' 

我錯過了什麼?

+0

你確實有一些事情在周後=這不是一個評論,對吧? – nPn 2014-09-24 02:07:01

+0

@nPn它是'week =''' - 與我引用的示例中的相同。 – user101289 2014-09-24 02:08:01

+0

我的意思是星期=#grap本週 – nPn 2014-09-24 02:08:35

回答

3

rails console在啓動時讀取您的應用程序代碼。因此,您需要在更改代碼後重新啓動您的rails console

0

每次在代碼中進行更改時,您必須重新啓動您的rails console

您可以使用此reload!命令重新啓動控制檯。