-3

バージョン> ruby​​ 1.9.2p290、Rails 3.1.0、Ubuntu 12.04

RoR アプリが application.html.halm を検出しません。そのため、HTML タグは解釈されず、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>
4

1 に答える 1

1

名前を変更:

app/views/layouts/application.htlm.halm

に:

app/views/layouts/application.html.haml
于 2013-03-11T13:43:23.153 に答える