嗨即時通訊新的紅寶石在軌道上。並遵循用戶指南。我得到了一些錯誤。我試圖搜索這個,但我找到了一個。問題是我們都有同樣的錯誤,但是當我試圖改變@posts = Post.all時,我仍然有一些錯誤,有人可以幫助我嗎?下面是我的代碼。 這是我post_controller.rbNoMethodError在帖子中#index
class PostsController < ApplicationController
def index
@posts = Post.all
end
def new
end
def create
#render text: params[:post].inspect
@post = Post.new(post_params)
@post.save
redirect_to @post
end
def show
@post = Post.find(params[:id])
end
private
def post_params
params.require(:post).permit(:title, :text)
end
end
而且我index.html.erb
<h1>Listings!</h1>
<table>
<tr>
<th>Title</th>
<th>Text</th>
</tr>
<tr>
<% @posts.each do |posts| %>
<tr>
<td><%= @posts.title %></td>
<td><%= @posts.text %></td>
</tr>
<% end %>
</tr>
</table>
當我試圖在本地主機上 訪問得到這個錯誤 在帖子#指數
請顯示您的config/routes.rb –