的Rails 4.1 &紅寶石2.0語法錯誤,意外 '',預計 ')' 與Rails4
下面是我在LIB/global_methods.rb:
def admin_status? (id = nil)
role_value = I18n.t 'admin_role'
unless id
current_user.role == role_value
else
determine_user_role (id, role_value)
end
end
def determine_user_role (id, role_value)
user = User.find_by id: id
user.role == role_value
end
下面是我在application_controller .RB
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
require ('json')
require ('csv')
require ('global_methods')
end
我收到以下錯誤:
syntax error, unexpected ',', expecting ')'
它指向application_controller.rb中的第7行作爲罪魁禍首。如果從global_method.rb中刪除函數,我不會再收到錯誤。我看不到語法問題。有任何想法嗎?
沒有嚴格相關,但基本上沒有人把parens放在「要求」的參數上。爲了便於閱讀,我建議不要這樣做。 –
是的,我剛開始沒有聖殿,但是在我複製代碼的時候,我花了大約一個小時的時間嘗試不同的事情來診斷問題。我會回到沒有parans。它更具可讀性 –