socialforge/app/models/journals_for_message.rb

24 lines
658 B
Ruby
Raw Normal View History

2013-08-04 10:59:25 +08:00
# fq
2013-08-01 10:33:49 +08:00
class JournalsForMessage < ActiveRecord::Base
attr_accessible :jour_id, :jour_type, :notes, :reply_id, :status, :user_id
attr_accessor :indice
belongs_to :jour, :polymorphic => true
belongs_to :user
def self.delete_message(message_id)
self.delete_all "id = #{message_id}"
end
def reference_user
User.find(reply_id)
end
def self.reference_message(user_id)
@user = User.find(user_id)
message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))")
message
end
2013-08-01 10:33:49 +08:00
end