Ruby: Outputting Sequel model associations
问题 I don't think this is possible using just Sequel models, but what I would like to do is have my parent model ( Author ) output its child model ( Book ) when I do something like Author.to_json . Here is my code: require 'sequel' require 'json' db = Sequel.connect('postgres://localhost/testing'); class Sequel::Model self.plugin :json_serializer end class Author < Sequel::Model(:author) one_to_many :book, key: :author_id, primary_key: :id def get_author Author.each do |e| books = Array.new e