ruby - Rails API Create Issue -


api application has create method looks like:

# post /posts # post /posts.json def create     @post = post.new(params[:post])      if @post.save       render json: @post, status: :created, location: api_v1_post_path(@post)     else       render json: @post.errors, status: :unprocessable_entity     end end 

and use curl command like:

curl --data "name=test" http://0.0.0.0:3000/api/v1/posts

which creates post, without name = test should be. help!

try out

curl --data "post[name]=test" http://0.0.0.0:3000/api/v1/posts 

Comments