I’ve just started learning Ruby on rails and I am wondering how to do something that I know how to easily do in PHP.
I want to create some basic web services that can be called with POST parameters and send a JSON as a response. I don’t know at all how to start with that using Ruby on rails.
I am sure there are some best practice to do that kind of things, so if you guys could advise me anything, it would be great!
Regards,
To get the POST parameters, you just look into the params hash in your controller, which will have any and all parameters for the request, whether they’re coming as POST params, GET params, or as part of the route (e.g. /users/:id/new => params[:id] in the controller)
To return json from the request, you’d just make a render call like this:
Beyond that, your question is a bit broad for the scope of an answer on SO. I recommend reading Agile Web Development with Rails as a starting point to learn Rails development.