基本的には、主題のコントローラ、モデル、ビューを作成しました。基本的に私はコントローラ内に6つのアクションを持っており、適切なファイルをルーティングするために私のルートファイル内にRESTを設定しています。Rails RESTは正しいページを表示/ロードしません - Ruby on Rails
私は、http://localhost:3000/subjects/indexに入ったとき、それはshow.html.erbのためのビューの代わりに、index.html.erb
はここに私の主題コントローラは次のようになります。私を示しています
class SubjectsController < ApplicationController
def index
@subjects = Subject.sorted
end
そして、ここです私のindex.html.erbファイルの内容。
<% @page_title = "All Subjects" %>
<div class="subjects index">
<h2>Subjects</h2>
<%= link_to("Add New Subject", new_subject_path, :class => "action_new") %>
<table class="listing" summary="Subject list" border="1">
<tr class="header">
<th>#</th>
<th>Subject</th>
<th>Visible</th>
<th>Pages</th>
<th>Actions</th>
</tr>
<% @subjects.each do |subject| %>
<tr>
<td><%= subject.position %> </td>
<td><%= subject.name %> </td>
<td class="center"><%= status_tag(subject.visible) %></td>
<td class="center"><%= subject.pages.size %> </td>
<td class="actions">
<%= link_to("View Pages", pages_path(:subject_id => subject.id), :class => 'action show') %>
<%= link_to("Show", subject_path(subject), :class => 'action show') %>
<%= link_to("Edit", edit_subject_path(subject), :class => 'action edit') %>
<%= link_to("Delete", delete_subject_path(subject), :class => 'action delete') %>
<td>
</tr>
<% end %>
<table>
</div>
はまた、ここで私は私のルートに設定したものです:
resources :subjects do
member do
get :delete
end
end
私が行方不明です何を任意のアイデア?
こんにちは返信ありがとうございます。私はそれにアクセスしてこれを得た。 http://prnt.sc/dx796n –
Nevermind。それは今働く。 –