basecrm-ruby
basecrm-ruby copied to clipboard
sync.fetch TypeError (wrong argument type Hash (expected String)): postgresql
I'm working on trying to implement the fetch method into my ruby app, and it does fire, however when trying to run the execute script i get the following error
TypeError (wrong argument type Hash (expected String)):
I can see the console output and it's obvious of why it's happening:
{:table=>"user", :statement=>"created", :properties=>#<BaseCRM::User id=660957, name="Richard Walsh", email="", created_at="2015-03-17T23:49:00Z", updated_at="2015-07-28T18:38:45Z", confirmed=true, role="admin", status="active">}
It's passing a hash instead of forming a sql insert statement, has anyone had any luck working this into postgresql?
base_sync.fetch do |meta, resource|
options = {
table: meta.type,
statement: meta.sync.event_type,
properties: resource
}
ActiveRecord::Base.connection.execute(options) ? meta.sync.ack : meta.sync.nack
end
I've tried to break resource down to get the keys and values as separate arrays even to create a sql insert statement, but I can't even seem to manage to get that working. The resource returns nil as I try to decompose it.
I should also note that I've implemented via Rails 4.