I m very new to rails .I need a app which an accept post request with json and create a object in database .I know that we can do this with active resource ? I can not find any very tutorial .I no need any index ,show views .I just need to use a create .
Asked
Active
Viewed 28 times
0
-
Hi... I'm aware that this question has been answered by some very kind and forgiving people on Stack Overflow... but normally, this question would be downvoted and closed as it really doesn't show very much research effort. Have you googled "active resource documentation" ? have you had a go at the code? or even just some pseudo-code? even if the code didn't work - you should always paste it into your question to show us that you've at least tried *something*... please do that in the future :) – Taryn East Jul 18 '14 at 07:55
2 Answers
2
I would start with commands like:
rails new jsoner
rails generate model json_converter # Add attribuest here, e.g. msg
rails generate controller json_converter # Add methods, e.g. json_to_db
Add a route in config/routes.rb
Make the controller have a respond_to :json
block

Michael Durrant
- 93,410
- 97
- 333
- 497
1
In general, you're gonna have to learn SOMETHING in order to do this. :)
In your case, I'd suggest skipping the broad, comprehensive (and sometimes baffling) feature set of Ruby on Rails and try Sinatra instead (http://www.sinatrarb.com/intro.html), which is a relatively lightweight framework that will likely meet your needs.
I don't usually like citing a Google search as an answer to a Stack Overflow question, but your question is so broad, it's probably for the best. Try:
https://www.google.com/search?q=sinatra+ruby+tutorial+json
... and see if any of those will get you started.

fearless_fool
- 33,645
- 23
- 135
- 217