views:

23

answers:

2

Here is the scope of the issue Im dealing with...

I just took over an existing rails app that has a very complex business logic. The app is being used as a service. Json in, Json out.

Some of the resources expecting to find an abstract model in params hash and then via meta programming it expects to find the right object properties provided.

Giving that i have no docs, or unit tests, etc I'm finding it very difficult to figure out what to include in the params hash so the post/put operatins succeeds.

+1  A: 

Are you able to boot it up with rails server and use the service? If so, you can just track what params it actually uses by adding <%= debug(params) if Rails.env.development? %> to your layout.

Jonathon Jones
Yeah but I have no HTML views it only renders json out
theKing
A: 

I suspect you don't know how to POST web requests to your JSON API. Try curl:

curl -fname=ariejan -fother_params=1 -fanother_param=@filename http://localhost:3000/test.json

Add the -f option automatically makes curl do a POST request. You'll get back the server response in JSON as well.

Ariejan
No I do but I'm using HTTParty gem. But that doesn't answer my question. I'm trying to find out about the "expected" params hash. This particular service expects a very complex 7-8 level deep nested hash/json
theKing