Skip to content

Instantly share code, notes, and snippets.

@kulbida
Forked from metaskills/gist:977846
Created December 21, 2013 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kulbida/8073596 to your computer and use it in GitHub Desktop.
Save kulbida/8073596 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
has_many :columns
def as_json(options={})
attributes.slice(:id, :email, :uuid).merge(:columns => columns)
end
end
class Column < ActiveRecord::Base
belongs_to :user
has_many :boxes
def as_json(options=nil)
attributes.slice(*JSON_ATTRS).merge(:boxes => boxes)
end
end
class Box < ActiveRecord::Base
belongs_to :column
has_many :bookmarks
def as_json(options=nil)
attributes.slice(:id, :column_id, :title, :style, :collapsed, :position).merge(:bookmarks => bookmarks)
end
end
class Bookmark < ActiveRecord::Base
belongs_to :box
def as_json(options=nil)
attributes.slice(:id, :owner_id, :owner_type, :url, :name, :position)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment