I’m trying to add a public API to my app to allow users to add items into my application through API calls.
I’m kind of confused though…..
I have this so far which outputs a great xml page with all our Model data so perfect….
def index
@events = Event.all
respond_to do |format|
format.html
format.xml { render :xml => @events }
format.json { render :json => @events }
end
end
So I’m assuming I would be able to add that same respond_to block into the CREATE or NEW action (which one?) and get some form of API functionality there as well??? but I’m confused to how this whole process works…
For example if my Event model only had one field => name:string
How would I be able to add a record by webservice?
???? ==> curl http://localhost:3000/events[??????add??????]
See this post on using cURL to test REST applications.
Quoting: