2010-04-18 46 views
1

有什麼辦法來抑制application.html.erb在視圖基礎上加載的默認js和css?我發現管理全局CSS非常困難,而且當某些視圖需要不同的js庫(由於某種原因似乎彼此衝突)時,js包含配置。例如,我可能想要一個視圖的jquery 1.3和另一個視圖的1.4.2。我不一定希望爲每個視圖都包含一個(我確實希望擁有一個全局的站點範圍的默認值),但是我也希望能夠覆蓋那些用於任何我想要的視圖。謝謝!抑制/覆蓋application.html.erb

回答

0
# Renders the template for the action "long_goal" within the current controller, 
# but with a custom layout 
render :action => "long_goal", :layout => "spectacular" 

See the documentation for render

所以,你可以做到這一點,例如:

def show 
    respond_to do |wants| 
    wants.html { render :action => 'show', :layout => 'other_layout' } 
    end 
end 

但是,這僅僅是一個哈克繃帶。你應該看看爲什麼jQuery的兩個版本衝突。

+0

好的,謝謝!我肯定用jQuery來調查問題。 – 2010-04-18 20:43:06