method

create

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 1 note - Class: PostsController
create() public

POST /posts POST /posts.json

Show source
Register or log in to add new notes.
May 5, 2014 - (v3.2.13)
0 thanks

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