method

create

rails latest stable - Class: PostsController

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.2.13) is shown here.

create()
public

POST /posts POST /posts.json

1Note

another way

e-vive ยท May 4, 2014

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