Rémy Thellier
Rémy Thellier

Reputation: 169

How to send the correct request to my rails-api thanks to ng-resource?

I created an API using the rails-api gem and I have an client app based on angular in which I use ng-resource.

I do think that the request I send to my API should be more like {post=>{"kind"=>"GGG"}} and not {"kind"=>"GGG"} of I have to find a way for my api to work with the request I send now. For now I'm stuck with 400 Bad Request errors and I can't find out how to fix it.

-

Upvotes: 2

Views: 865

Answers (1)

Joey Hu
Joey Hu

Reputation: 448

Change the following code:

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

To be:

def post_params
  params.permit(:post, :kind)
end

And you problem will be fixed.

Upvotes: 4

Related Questions