레일 환경에서 루비를 코딩하는 법을 배우고 있습니다. 나는 두 가지 모델의 자동차와 제품을 만들었습니다. 자동차와 제품에 대한 링크가있는 메인 페이지를 갖고 싶습니다. 각각을 클릭하면 자신의보기 페이지를 표시해야합니다. 다음은 자동차와 사용자를위한 뷰 페이지는 각각 다음과 같습니다레일에서 루비보기
응용 프로그램/뷰/자동차/index.html.erb
<p id="notice"><%= notice %></p>
<h1>Listing Cars</h1>
<table>
<thead>
<tr>
<th>Make</th>
<th>Color</th>
<th>Year</th>
<th colspan="24"></th>
</tr>
</thead>
<tbody>
<% @cars.each do |car| %>
<tr>
<td><%= car.make %></td>
<td><%= car.color %></td>
<td><%= car.year %></td>
<td><%= link_to 'Show', car %></td>
<td><%= link_to 'Edit', edit_car_path(car) %></td>
<td><%= link_to 'Destroy', car, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Car', new_car_path %>
<h4>Import that data!</h4>
<%= form_tag import_users_path, multipart: true do %>
<%= file_field_tag :file %>
<%= submit_tag "Import CSV" %>
<% end %>
</div>
응용 프로그램/뷰/사용자/index.html.erb
<p id="notice"><%= notice %></p>
<h1>Listing Users</h1>
<table>
<thead>
<tr>
<th>User</th>
<th>Steps</th>
<th>Distance</th>
<th>Minutes Exercised</th>
<th>Hours of Sleep</th>
<th>Calories Burned</th>
<th colspan="24"></th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.user %></td>
<td><%= user.steps %></td>
<td><%= user.distance %></td>
<td><%= user.exercise %></td>
<td><%= user.sleep %></td>
<td><%= user.calories %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New User', new_user_path %>
<div>
<h4>Import that data!</h4>
<%= form_tag import_users_path, multipart: true do %>
<%= file_field_tag :file %>
<%= submit_tag "Import CSV" %>
<% end %>
</div>
<%= form_tag import_users_path, multipart: true, class: 'form-inline' do %>
<div class="form-group">
<%= link_to "Export CSV", users_path(format: "csv"), class: 'btn btn-primary' %>
</div>
<% end %>
단일 기본 페이지를 작성하고 이러한보기에 대한 링크를 제공하는 방법을 모르겠습니다. 한 가지 예가 나를 도울 것입니다. 선배 들께 감사드립니다.
당신은 예를 들어, 정적 페이지를 만드시겠습니까 각 모델 색인보기에 대한 링크가있는 홈 페이지? –