Sha256: a250c7e29f0635d3273778b3f242e80400ac2c7ecea329a432f715f49c2bd528

Contents?: true

Size: 639 Bytes

Versions: 2

Compression:

Stored size: 639 Bytes

Contents

#!/usr/bin/env ruby -rubygems

require File.dirname(__FILE__) + '/authentication'

# create a resource without fetching the collection
klass = StorageRoom.class_for_name('Guidebook')
resource1 = klass.new(:name => 'Foo', :price => 1.23)

if resource1.save
  puts "Resource saved"
else
  puts "Resource could not be saved: #{resource1.errors.join(', ')}"
end

# fetch the collection first
collection = StorageRoom::Collection.find('guidebooks')

resource2 = collection.resource_class.new(:name => 'Bar', :price => 2.23)

if resource2.save
  puts "Resource saved"
else
  puts "Resource could not be saved: #{resource2.errors.join(', ')}"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
storage_room-0.1.1 examples/create_resource.rb
storage_room-0.1.0 examples/create_resource.rb