Skip to content

Instantly share code, notes, and snippets.

@fidothe
Created March 18, 2015 09:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fidothe/39d4ef9b8d84f8ddde77 to your computer and use it in GitHub Desktop.
Save fidothe/39d4ef9b8d84f8ddde77 to your computer and use it in GitHub Desktop.
Use PG JSON datatype with Lotus::Model (hacky hacky)
require 'lotus/model'
require 'json'
module Lotus::Model::Mapping::Coercions
def self.JSON(arg)
return nil if arg.nil?
case arg
when String
JSON.parse(arg)
else
Sequel.pg_json(arg)
end
end
end
Lotus::Model.configure do
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment