Search code examples
ruby-on-railsjsonruby-on-rails-3activeresource

Need a create a simple app which accepts a json file and updates the database


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 .


Solution

  • 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