ERB中的Ruby脚本未被读取

时间:2015-08-19 08:56:20

标签: html ruby-on-rails ruby erb

这是index.html.erb:

<h1>Bookmarks</h1>
t
<% @books.each do |b| %>
  <div class="book">
    e
    <div class="row">
      s
      <div class="col-md-1">
        t
        <p class="rank-this-week">
          <%= b.rank_this_week %> </p>
      </div>
      <div class="col-md-9">
        <p class="title"> <%= b.title %> </p>
        <p class="author">by  <%= b.author %></p>
        <p class="publisher">(<%= b.publisher %>)</p>
        <p class="description"> <%= b.description %> </p>
        <%= link_to 'See all Editorial Reviews', b %>
      </div>
      <div class="col-md-2">
        <p class="weeks-on-list"><%= b.weeks_on_list %></p>
      </div>
    </div>
  </div>
<% end %>

这是图书管理员

 class BooksController < ApplicationController
  def index
    @books = Book.all
  end

  def show
    @book = Book.find(params[:id])
    @reviews = @book.reviews
  end
end

我已通过resources :books路由 routes.rb 中的资源,db/migrate中存在所有对象的元素。书籍上已经播放了大量的参赛作品。还运行了rake db:seed。问题是,在查看页面时,只显示<h1>标记书签和t。没别了。

请帮助,真的试图打击RoR。任何帮助赞赏。

编辑:种子文件非常大,但这里是一致的样本。

b1 = Book.create(title: "American Sniper", author: "Chris Kyle, Scott        McEwen, Jim DeFelice", description: "A memoir about battlefield experiences in Iraq by the Navy SEALs sniper.", publisher: "Morrow/HarperCollins", weeks_on_list: 63, rank_this_week: 1)
b2 = Book.create(title: "Unbroken", author: "Laura Hillenbrand", description: "An Olympic runner’s story of survival as a prisoner of the Japanese in World War II after his plane went down over the Pacific.", publisher: "Random House", weeks_on_list: 25, rank_this_week: 2)
b3 = Book.create(title: "Wild", author: "Cheryl Strayed", description: "A woman’s account of the life-changing 1,100-mile solo hike she took along the Pacific Crest Trail in 1995.", publisher: "Vintage", weeks_on_list: 95, rank_this_week: 3)

1 个答案:

答案 0 :(得分:0)

由于大量评论我解决了!我意识到我在运行rake db:seed什么都没有通过,但它很可能是一个错字导致播种错误。