using ActiveResouce to manipulate Webistrano hosts

7 views
Skip to first unread message

piavlo

unread,
Jul 7, 2011, 6:26:34 AM7/7/11
to Webistrano
Hi,

I'm trying to use ActiveResouce to modify hosts.

So far I came up with the following

require 'rubygems'
require 'active_resource'

class Hosts < ActiveResource::Base
self.site = "http://localhost:3300"
self.user = "user"
self.password = "pass"
end

Trying to create new host with Hosts.create(:name =>
"blah.example.org") - I get the following

ruby-1.8.7-p352 :009 > Hosts.create(:name => "blah.example.org")
=> #<Hosts:0x7f7fe87f0908 @prefix_options={}, @remote_errors=nil,
@errors=#<OrderedHash {}>, @attributes={"name"=>"blah.example.org",
"id"=>nil, "error"=>["Name can't be blank", "Name is too long (maximum
is 250 characters)", "Name is not a valid hostname or IP"]},
@validation_context=nil>
ruby-1.8.7-p352 :010 >

And the node is not being created.

Any clues how I can do it?

Thanks
Alex
Reply all
Reply to author
Forward
0 new messages