i just cant figured out what kind of error i get. i stuck in editing. So here's my code
posts_controller.rb
class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def create
@post = Post.new(user_params)
# @post = Post.new(params[:post])
if @post.save
redirect_to posts_path, :notice => "Your post was saved"
else
render "new"
end
end
private
def user_params
params.require(:post).permit(:title, :content)
end
def edit
@post = Post.find(params[:id])
end
def update
end
def destroy
end
end
And here's my edit.html.erb
<h1>Edit Post</h1>
<%= form_for @post do |f| %>
<p>
<%= f.label :title %>
</p>
<% end %>
And the error i got is "First argument in form cannot contain nil or be empty"
Aucun commentaire:
Enregistrer un commentaire