Ruby on Railsの学習を始めています。私はmovies_controllerに次のコードを持っています。Rails 5コントローラがデータベースからデータを配列としてダンプする
class MoviesController < ApplicationController
def index
@movies = Movie.all
end
end
、私index.html.erbは次のようにデータベースからデータを表示するテーブルの構造を有する:
<h4><%= pluralize(@movies.size, 'Movie') %> Found</h4>
<table>
<tr>
<th>Movie Title</th>
<th>Rating</th>
<th>Gross Revenue</th>
</tr>
<%= @movies.each do |movie| %>
<tr>
<td><%= movie.title %></td>
<td><%= movie.rating %></td>
<td><%= number_to_currency(movie.total_gross) %></td>
</tr>
<% end %>
</table>
index.html.erb最初アレイとして全ムービーデータをダンプ上記のテーブル構造の下にそのデータを表示します。私は何が間違っていますか?ありがとう。
何をする予定ですか? – moveson
訂正していただきありがとうございます。 – humanshado