2011-07-25 29 views
1

我在我的ApplicationController中定義了一些輔助方法。對於性能問題,我有一個用於/search路由的Rack應用程序,我需要在此Rack中使用其中的一些方法。我現在無法將他們移動到圖書館或其他地方。Rails:在Rack應用程序中加載helper_method方法?

簡單例子:

class ApplicationController < ActionController::Base 
    helper_method :user_participants 
    ... 
end 

而且在機架:

class SearchRack 
    def self.call(env) 
    # need to call user_participants here 
    end 
end 

我能做些什麼?

感謝,

回答

0

你將需要把它們搬出一個模塊,然後包括模塊機架應用程序內和ApplicationController內爲好。我想不出另一種方式去做,而且這是最乾淨的。

相關問題