2013-04-17 40 views
0

我一直在試圖讓我的項目在Cloud Foundry上停留一段時間,並最終將我的問題縮小到此項目進入生產模式。在從開發模式切換到生產模式時所遇到的所有錯誤中,我以某種方式設法得到了「意外結束」錯誤。罪魁禍首是在一個控制器,看到如下:Rails生產模式'結束'錯誤?

companiesController < ApplicationController 
    skip_before_filter :require_login 
    end 
    #def new 

這段代碼下面有評論的負載,但沒有別的。該skip_before_filter是指在應用程序控制器中的前過濾器,它看起來像這樣:

class ApplicationController < ActionController::Base 
    protect_from_forgery 
    include SessionsHelper  

    before_filter :require_login 

def current_company 
    Company.find_by_subdomain! request.subdomain 
end 
helper_method :current_company 

def scope_current_company 
    Company.current_id = current_company.id 
    yield 
ensure 
    Company.current_id = nil 
end 

def require_login 
    if current_user == nil 
    flash[:failure] = "You must log in to access that resource" 
    redirect_to signin_path 
    end 
end 
end 

只是爲了完整起見,我還要提到的是這個應用程序還包括基於子域多租戶。子域基於數據庫中的租戶表。我只是這樣說,以澄清對代碼的任何困惑,但如果它有助於揭示這個問題,那麼這也很棒!我已經拿出了所有關於多租戶和子域的參考,並且只是想讓這個項目進入生產模式,所以不應該影響它。

確切的錯誤狀態是您在顯示的代碼中的公司控制器中的平均「意外的關鍵字結束,期待$結束」,它對我沒有任何意義,但我的意思是需要有一個到此爲止。爲什麼會抱怨我是無法理解......

任何幫助,將不勝感激。

回答

2

是真正爲CompaniesController代碼嗎?你知道類應該是這樣,而不是界定?

class CompaniesController < ApplicationController 
    skip_before_filter :require_login 
end 

另外,如果你正在用Rails做多租戶的東西,你可能想看看我的書:Multitenancy with Rails

+0

我正要寫相同的答案。我無法弄清的事實是@Marc控制器的代碼如何在開發環境中工作? – Jef

+0

我不能相信我錯過了那麼明顯的事情......我必須改變它,然後忘記它。幾個小時後,我一直在努力工作,並且精疲力竭!謝謝你們的幫助! – Marc