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?

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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
Then that's a completely different question; not a ruby-on-rails question but an iOS question. See stackoverflow.com/questions/5537297/…
Thank you for helping! Can i POST from ios app to website db via json or there is another way to do it?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.