Skip to content

Instantly share code, notes, and snippets.

@ananyo2012
Created Jan 3, 2017
Embed
What would you like to do?
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