2013-03-11 55 views
-3

版本>紅寶石1.9.2p290來說,Rails 3.1.0,Ubuntu的12.04Rails不reconize application.html.haml

我的RoR應用程序不檢測application.html.halm。所以HTML標籤沒有被解釋,de CSS和其他常見文件沒有被包含在內。意見其餘的渲染HALM並正在努力:)

這裏我的應用程序控制器

class ApplicationController < ActionController::Base 
    protect_from_forgery 
end 

電影控制器

# This file is app/controllers/movies_controller.rb 
class MoviesController < ApplicationController 
    def index 
    @movies = Movie.all 
    end 

    def show 
    id = params[:id] 
    @movie = Movie.find(id) 
    # will render app/views/movies/show.html.haml by default 
    end 
    def new 
    # default render 'new' template 
    # debugger 
    end 
    def create 
    @movie = Movie.create!(params[:movie]) 
    flash[:notice] = "#{@movie.title} was succesfully created." 
    redirect_to movies_path 
    end 
end`# This file is app/controllers/movies_controller.rb 
class MoviesController < ApplicationController 
    def index 
    @movies = Movie.all 
    end 

    def show 
    id = params[:id] 
    @movie = Movie.find(id) 
    # will render app/views/movies/show.html.haml by default 
    end 
    def new 
    # default render 'new' template 
    # debugger 
    end 
    def create 
    @movie = Movie.create!(params[:movie]) 
    flash[:notice] = "#{@movie.title} was succesfully created." 
    redirect_to movies_path 
    end 
end 

應用程序/視圖/佈局/ application.htlm.halm

!!! 5 
%html 
    %head 
    %title Rotten Potatoes! 
    = stylesheet_link_tag 'application' 
    = javascript_include_tag 'application' 
    = csrf_meta_tags 

    %body 
    = yield 

解釋的結果是注意到缺少HTML和其他標籤:

<h2>All Movies</h2> 
<table id='movies'> 
    <thead> 
    <tr> 
     <th>Movie Title</th> 
     <th>Rating</th> 
     <th>Release Date</th> 
     <th>More Info</th> 
    </tr> 
    </thead> 
    <tbody> 

    <tr> 
     <td>EEEe</td> 
     <td>G</td> 
     <td>2013-02-27 00:00:00 UTC</td> 
     <td><a href="/movies/27">More about EEEe</a></td> 
    </tr> 
    </tbody> 
</table> 
<a href="/movies/new">Add new movie</a> 

回答

1

重命名:

app/views/layouts/application.htlm.halm 

到:

app/views/layouts/application.html.haml 
+2

有時簡單的東西是殺你的人。謝謝我的錯誤! – 2013-03-11 16:12:14