2012-08-12 73 views
1

我使用HAML作爲我的標記語言。 而我的視圖只呈現自我視圖,沒有佈局應用程序。如果我的方法我寫Rails沒有渲染標準的HAML佈局

渲染:佈局=>真

我會得到

有用於HomesController沒有默認佈局

/家/pavel/.rvm/gems/ruby-1.9.3-p194/gems/kaminari-0.13.0/app/views]>

但是,如果我將application.html.haml重命名爲application.html.erb,則一切正常。但腳手架產生HAML沒有問題。怎麼了?

class HomesController < ApplicationController 
    def index 
    @manufacturers = Manufacturer.all 
    #render :layout => 'application' 
    end 
end 

視圖

%ul 
    - @manufacturers.each do |manufacturer| 
    %li  
     = link_to manufacturer.MFA_BRAND, vehiclemodel_url(:id => manufacturer.MFA_ID) 

佈局

!!! 
%html 
    %head 
    %title Title 
    = stylesheet_link_tag "application" 
    = javascript_include_tag "application" 
    = csrf_meta_tags 
    %body 
    - if current_user 
     = "Signed in as #{current_user.email}. Not you?" 
     = link_to "Sign out", logout_path 
    - else 
     = link_to "Sign in", new_user_session_path 
    %p 
     Hello! 
    %h4 
     =yield 

回答

1

我創辦的解決方案: 在Gemfile中必須

寶石 'HAML護欄'

因此,寶石HAML是不需要在那裏,只有HAML護欄。

0

你加

gem 'haml' 

到你的Gemfile?

+0

當然,也有haml-rails – byCoder 2012-08-12 12:57:56

+0

而且你在你改變Gemfile後立即運行'bundle install'? (對不起,如果這是一個明顯的問題,但我得檢查。) – depa 2012-08-12 13:13:16

+0

是的!問題不在於此 – byCoder 2012-08-12 13:14:08