Created
January 3, 2017 04:14
-
-
Save ananyo2012/dca9c229a84cedc92e7a3d726965535e to your computer and use it in GitHub Desktop.
Node model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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