0
show.html.erb
<% @posts.each do |post|%>
<h1><strong>Title</strong></h1>
<%= post.Title.upcase %>
<h2><i>name</i></h2>
<%= post.Name.capitalize %>
<p>
<b>Message</b>
<%=post.Message %>
</p>
<% end -%>
柱控制器
class PostsController < ApplicationController
def index
@posts =Post.all
end
def new
@posts =Post.new
end
def create#no view just for the saving process
@posts = Post.new(ok_params)
if @posts.save
redirect_to posts_path
else
render 'new'
end
end
def show#we will use it to view the whole mesage
@posts=Post.find(params[:id])
end
def edit
@posts=Post.find(params[:id])
end
def update
@posts=Post.find(params[:id])
if @posts.update_attributes(ok_params)
redirect_to posts_path
else
render 'new'
end
end
def destroy
@posts=Post.find(params[:id])
@posts.destroy
redirect_to posts_path
end
private
def ok_params
params.require(:post).permit(:Title, :Name, :Message, :Comments)
end
end
但是,當在服務器中的應用程序運行(我使用薄的,而不是PUMA)表示一個「未知方法##每個」的NoMethod錯誤 the NoMethod error in the show templateNomethod誤差在展示模板