0

I'm trying to create record in db via json. The problem is that i don't know how to compose http request in URL bar:

It should be something like:

http://localhost:3000/addnewpost.json?content=sometexthere

Or this is not correct?

Bennington
  • 295
  • 4
  • 13

1 Answers1

1

It's not correct. Creating a record should be a POST command, not a GET. As such, the data content should go in the POST headers, not in the URL.

Are you sending this POST directly from Ruby? (if so, you'll want to look at Net::HTTP or some other ruby HTTP client). Show us some code and we'll help you improve it.

Jacob Mattison
  • 50,258
  • 9
  • 107
  • 126
  • I'm creating an ios app for my website. I get info using rabl gem, but i don't know how to POST from ios app to my website's db – Bennington Feb 16 '13 at 16:05
  • Then that's a completely different question; not a ruby-on-rails question but an iOS question. See http://stackoverflow.com/questions/5537297/ios-how-to-perform-a-http-post-request – Jacob Mattison Feb 16 '13 at 16:06
  • Thank you for helping! Can i POST from ios app to website db via json or there is another way to do it? – Bennington Feb 16 '13 at 16:17
  • 1
    Not sure what you mean by "website db". If you have a Rails application that accepts POST commands with JSON content and creates DB records, then you should POST to that application from your iOS app, with the POST data in JSON format. This is an entirely reasonable approach -- an iOS app backed by a Rails web service. – Jacob Mattison Feb 16 '13 at 16:23