Skip to content

Instantly share code, notes, and snippets.

@ananyo2012
Created January 3, 2017 04: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 ananyo2012/dca9c229a84cedc92e7a3d726965535e to your computer and use it in GitHub Desktop.
Save ananyo2012/dca9c229a84cedc92e7a3d726965535e to your computer and use it in GitHub Desktop.
Node model
class Node < ActiveRecord::Base
include NodeShared # This includes the NodeShared Concern
attr_accessible :title, :uid, :status, :type, :vid, :cached_likes, :comment, :path, :slug
self.table_name = 'node'
self.primary_key = 'nid'
has_many :node_selections, :foreign_key => :nid
has_many :answers, :foreign_key => :nid
def latest
self.revisions
.where(status: 1)
.first
end
def revisions
self.drupal_node_revision
.order("timestamp DESC")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment