method
create
rails latest stable - Class:
PostsController
create()public
POST /posts POST /posts.json
1Note
another way
Perhaps a more efficient way:
def create
@post = Post.new(post_params)
if @post.save
redirect_to @post, notice: "The post #{@post.title} was added to the system."
else
render action: 'new'
end
end
where post_params is:
private
def post_params
params.require(:post).permit(..attributes to permit..)
end