Sha256: 1f426bd6791aaafa2c1dd993370c699046b4feb52e77169e0e9216638be86adb

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

case Merit.orm
when :active_record
  class Comment < ActiveRecord::Base
  end
when :mongoid
  class Comment
    include Mongoid::Document
    include Mongoid::Timestamps

    field :name, :type => String
    field :comment, :type => String
    field :votes, :type => Integer
  end
end

class Comment
  has_merit

  belongs_to :user

  if defined?(ProtectedAttributes) || !defined?(ActionController::StrongParameters)
    attr_accessible :name, :comment, :user_id, :votes
  end

  validates :name, :comment, :user_id, :presence => true

  delegate :comments, :to => :user, :prefix => true

  def friend
    User.find_by_name('friend')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
merit-1.9.0 test/dummy/app/models/comment.rb
merit-1.8.0 test/dummy/app/models/comment.rb