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'
我错过了什么?
你确实有一些事情在周后=这不是一个评论,对吧? – nPn 2014-09-24 02:07:01
@nPn它是'week =''' - 与我引用的示例中的相同。 – user101289 2014-09-24 02:08:01
我的意思是星期=#grap本周 – nPn 2014-09-24 02:08:35