Rails serialization error for async geocoding with ahoy gem using mongoid - mongoid

I have a Rails 5 app, running both a postgresql DB for application data and MongoDB (mongoid) for analytics, generated by the fantastic ahoy gem.
Everything works great until I switch to asynchronous geocoding in config/initializers/ahoy.rb, which generates the error below:
ActiveJob::SerializationError (Unsupported argument type: Visit):
The app is using delayed_job, for background processing.
I there a workaround for this issue, or is this caused by incompatibility between mongoid and delayed_job?

Try adding the GlobalId mixin to your model
class Visit
include GlobalID::Identification
end

Related

CakePhp3.2 ORM ResultSet and ORM Query Error running skeleton app on shared host

Been running cake app on shared host, which worked great until recently. The shared host supports Apache,PHP 5.4.45 through to PHP 7.0.21 and Mysql Server 5.6.35.
FYI - A skeleton app throws up the same error. This error is thrown way before database connection is made.
Below is the error am getting, the same app works ok on my local server.
Fatal error: Class Cake\ORM\ResultSet contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Iterator::current) in /projects/vendor/cakephp/cakephp/src/ORM/ResultSet.php on line 593
Fatal error: Cannot instantiate abstract class Cake\ORM\ResultSet in /vendor/cakephp/cakephp/src/ORM/Query.php on line 922
Looking forward to your insights on above.
Currently it looks like that this is the result of a bug in PHP:
https://github.com/cakephp/cakephp/issues/10936
https://github.com/cakephp/chronos/issues/147
https://bugs.php.net/bug.php?id=74833
Make sure to update to the latest CakePHP version, and if you the problem persists, try switching to PHP 5.6 until a fixed PHP version, or a workaround is available.

Relay JS only on client side

I have developed a graphql server with laravel (https://github.com/Folkloreatelier/laravel-graphql). Now I would like to create a React application by using Relay. When I create my first component, then I receive the error:
Uncaught Error: Invariant Violation: RelayQL: Unexpected invocation at runtime. Either the Babel transform was not set up, or it failed to identify this call site. Make sure it is being used verbatim as Relay.QL.
I still googled the error and I recognized that I need to install the Babel Relay Plugin. But to include this plugin I have to specify a schema. But I still have specified this schema on server side, why do I need this also in client side? Is there any example how to implement this when a server is still implemented (external server, e.g. no NodeJS server).
Thank you for your advice.
The schema for your data on the server-side is required by babel-relay-plugin to do transpilation of Relay.QL fragments in Javscripts that will be delivered to the client-side. However, note that on your GraphQL server, you define the schema in Laravel GraphQL PHP classes, which you need to convert it into JSON format that babel-relay-plugin expects.
For example, I did a similar setup with Rails and graphql-ruby (https://github.com/nethsix/relay-on-rails).
Define the data schema on my server-side using graphql-ruby classes in app/graph directory
Convert the schema into a JSON file using a script lib/tasks/graphql.rake, which I then stash into app/assets/javascripts/relay/data/schema.json
Point to the schema.json in your babelRelayPlug.js file wherever it is (mine is in assets/javascripts/relay/utils/babelRelayPlugin.js)
For Rails, we can easily dump the graphql-ruby schema to json by just calling #to_json method. You may have similar methods in PHP.
I compared the difference between setting up Relay on a nodejs server, vs. a non-nodejs server using an illustration here if it helps (https://medium.com/#khor/relay-facebook-on-rails-8b4af2057152)

Possible to access Piwik getVisitorLog through HTTP API?

I'm building some reporting tool. Ideally I want to avoid going through web server logs myself and use (some of) the power of Piwik.
The stuff I get from the visitor log would be a good start, this is at http://example.com/piwik/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday#/module=Live&action=getVisitorLog&idSite=1&period=day&date=yesterday
Unfortunately I can't find a getVisitorLog action in the HTTP API docs at
http://developer.piwik.org/api-reference/reporting-api#Actions (and it's also not an undocumented feature, method=Actions.getVisitorLog gives me
The method 'getVisitorLog' does not exist or is not available in the module '\Piwik\Plugins\Actions\API'.
Is there another way to get to this? Or should I write a plugin for Piwik?
Apparently it is possible through the Live plugin API:
http://developer.piwik.org/api-reference/reporting-api#Live
This works as desired:
http://example.com/piwik/index.php?module=API&method=Live.getLastVisitsDetails&format=JSON&idSite=1&period=day&date=2015-07-21&expanded=1&token_auth=XXXXX&filter_limit=100

Grails dbm-changelog-sync No such property

I am building a Grails app and was asked to integrate with liquibase. After a bit of research I found that the Database Migration plugin is the preferred method for this.
However, whenever I run any command involving the plugin, I get the following error:
Error executing script DbmChangelogSync: No such property: database for class: _DatabaseMigrationCommon_groovy
I am using database-migration version 1.3.6. I also tried with 1.3.8 but received the same error.
Any advice? Thanks.

Creating a Ruby gem to Access a Second Database from Multiple Rails Applications

We have a few Rails 3 web sites that need to access a common database for order tracking and fulfillment.
Basically we want each site to have its own database and be able to access the common database as well.
I am thinking that creating a gem to access this second database is the way to go, but I am fairly new to Ruby and Rails.
Anyone done something like this before?
Any suggestions on how to implement this?
Try with something like:
# WARNING: untested code
module DatabaseA
class Connection < ActiveRecord::Base
self.abstract_class = true
establish_connection :my_custom_connection
end
def const_missing(name)
model = Class.new(Object.const_get(name))
model.connection = Connection.connection
const_set(name, model)
end
end
Then you should use your models from this module:
DatabaseA::User.new
I have written a gem to help with this: https://github.com/karledurante/secondbase
We use it in production now with rails 2 and rails 3 apps.

Resources