這是錯誤,當我在「新帖點擊我越來越:新崗位 - 在形式上第一個參數不能包含零或爲空
形式第一個參數不能包含零或爲空
我PostController中:
class PostsController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
def index
@posts = Post.all
end
def show
end
def edit
end
def update
@post.update(post_params)
redirect_to posts_path
end
def new
if user_signed_in?
@post = Post.new
else
flash[:alert] = ":("
end
end
def create
@post = Post.new(post_params)
@post.user_id = current_user.id
@post.save
redirect_to posts_path
end
def destroy
if user_signed_in?
@post.destroy!
else
flash[:alert] = ":("
end
redirect_to posts_path
end
private
def post_params
params.require(:post).permit(:body)
end
def set_user
@post = Post.find(params[:id])
end
末
和帖子#指數:
<% @posts.each do |post| %>
<%= post.body %>
<%= link_to 'Show', post %>
<%= link_to 'Edit', edit_post_path(post) %>
<%= link_to 'Delete', post, method: :delete %>
<br>
_form.html.erb
<%= form_for(@post) do |f| %>
<div class="field">
<%= f.label :body %><br>
<%= f.text_area :body %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
它看起來像你的文章大多是代碼;請添加更多details.It看起來像你的文章主要是代碼;請添加更多details.It看起來像你的文章主要是代碼;請添加更多details.It看起來像你的文章主要是代碼;請添加更多details.It看起來像你的文章主要是代碼;請加一些細節。:(
錯誤犯規出現時,即時通訊在 – fuskie
登錄請發表你的所有錯誤信息得到。 –