How to update a model attribute in a RESTful Rails web app via a ruby script using rest-client gem.


Create the following app

rails new star
cd star
rails generate scaffold PronStar name:string action:string
rake db:migrate
rails s

install rest-client gem

gem 'rest_client'

Then assuming that you want to update a pron_star with id = 1 via a ruby script and the server is running on your pc, execute:

# update_pron_star.rb
require 'rest_client'
RestClient.put("", :pron_star => { :name => "Sexy", :action => "all" })


[1] rest-client