url = "http://localhost:3000/branches"
resource = RestClient::Resource\.new url \+"/"\+$param\["id"\]
puts resource
begin
response = resource\.get :content\_type => :json, :accept => :json
case response\.code
when 200
puts response\.to\_s
end
rescue => e
puts e
end
end
Here just i pass the ID through command line ie ruby newrest.rb id="22".
I don't see in the code where the method retrieve is called, so I
would not expect ruby newrest.rb to do anything.
Also I don't see how the command line value id is being loaded into
$param. Normally for ruby command line args I use ARGV or
OptionParser. Google for ruby command line parameters and you will
find how to do it.
url = "[http://localhost:3000/branches](http://localhost:3000/branches)"
resource = RestClient::Resource.new url +"/"+$param["id"]
puts resource
begin
response = resource.get :content_type => :json, :accept => :json
case response.code
when 200
puts response.to_s
end
rescue => e
puts e
end
end
Here just i pass the ID through command line ie ruby newrest.rb id=“22”.
I don’t see in the code where the method retrieve is called, so I would not expect ruby newrest.rb to do anything.Also I don’t see how the command line value id is being loaded into$param. Normally for ruby command line args I use ARGV orOptionParser. Google for ruby command line parameters and you will find how to do it.