我在rails app中有这样的
方法:
def current_user
return @current_user if @current_user.present?
@current_user = current_user_session && current_user_session.record
end
我还没有用过.present?方法之前,我进入我的交互式ruby外壳玩它.
每当我使用xxx.present?它返回NoMethodError.如果xxx是字符串,数字,数组,则无关紧要.
我该如何使用这种方法?