Ask A Question

Notifications

You’re not receiving notifications from this thread.

Internal Server Error with Rails API only app on Heroku

MiquelVald asked in Rails

I'm deploying a Rails API only app with MongoDB Atlas on Heroku. I'm using Postman to test the application. When I do a GET request the response is null, but when I do a POST I get a Internal Server Error (500).

Using heroku logs --tail, I noticed an ArgumentError in a controller, I already tested this API locally and it didn't give me any problem.

This is the results of heroku log: https://prnt.sc/ylor8d
This is the post controller, line 20 is the if statement:

def create
@post = Post.new(post_params)

if @post.save
render json: @post, status: :created, location: @post
else
render json: @post.errors, status: :unprocessable_entity
end
end
And the function for parameters is this

def post_params
params.require(:post).permit(:title, :body)
end

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,584+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.