3
我正在使用google-api-client gem(我的Gemfile中爲gem google-api-client, '0.4.1'
)。下面的代碼導致錯誤uninitialized constant MyController::Google
:Rails 3:路由錯誤 - 未初始化的常量MyController :: Google
class MyController < ApplicationController
def index
@client = Google::APIClient.new
end
end
指定::Google::APIClient
沒有幫助,錯誤然後說uninitialized constant Google
。
只需在文件頂部添加一個require 'google/api_client'
就可以避免這種情況,所以看起來自動加載過程中出現錯誤。不知道這裏到底發生了什麼,指定Gemfile中的gem應該已經自動需要gem了,對吧?我已經重新啓動rails服務器btw。