2010-11-15 72 views
4

我嘗試按照https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview設置devise和omniauth並部署到heroku。本地主機沒有錯誤,但是當我推送到heroku時,應用程序崩潰。在heroku日誌中,我在omniauth_callbacks_controller.rb中發現了'未初始化的常量用戶'錯誤。我如何初始化用戶?我有heroku耙db:已經遷移。但我不能運行heroku控制檯,因爲應用程序崩潰,所以我不能檢查是否有用戶模型。 爲了您的信息,我產生由rails g omniauth_callbacks_controller控制器未初始化的常量錯誤部署到heroku時

控制器在heroku logs

/disk1/home/slugs/338566_ad6243a_bbb1-19eae435-d901-44ba-9dd5-baf36d656448/mnt/app/controllers/omniauth_callbacks_controller.rb:1: uninitialized constant Users (NameError) 

在omniauth_callbacks_controller.rb

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController 
    def facebook 
    @user = User.find_for_facebook_oauth(env["omniauth.auth"], current_user) 

    if @user.persisted? 
     flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook" 
     sign_in_and_redirect @user, :event => :authentication 
    else 
     session["devise.facebook_data"] = env["omniauth.auth"] 
     redirect_to new_user_registration_url 
    end 
    end 
end 
+0

你確定你的模型,用戶在提交併推送? (id:integer,email:string,encrypted_pa​​ssword:string,password_salt:string,reset_password_token:string,remember_token:字符串,字符串,主要字符串:001:0>用戶 =>用戶ID: – shingara 2010-11-15 15:24:13

+0

在本地主機上, remember_created_at:datetime,sign_in_count:integer,current_sign_in_at:datetime,last_sign_in_at:datetime,current_sign_in_ip:string,last_sign_in_ip:string,created_at:datetime,updated_at:datetime) – wizztjh 2010-11-15 15:26:02

+0

所以我認爲這是承諾,當我git推heroku主,它說迄今爲止,我做了git add。和git commit -m「wateva」 – wizztjh 2010-11-15 15:27:09

回答

3

確定用戶模型在Heroku的數據庫中創建?

在你端子(未鐵軌控制檯!)進入

heroku rake db:migrate 

這將遷移Heroku的DB的匹配你的代碼。你是否仍然有錯誤?

0

Heroku的需要與模型遷移,所以你需要運行

heroku rake db:migrate 

再刷新頁面,現在它的工作:)

相關問題