@sundevilyang 先报个名,当志愿者吧~哈哈
Mongoid 和 Heroku ... 好像就没遇见几个读正确的,包括一些公司的技术负责人,自己读正确的反而不好意思了
都是很实用的干货,赞!
看完了,很棒!
不要点编辑才能删嘛,直接把删除的图标放在回复后面不好吗?
#5 楼 @I_AM_NOT_DHH 让别人给你汇钱的时候,你能告诉他一个错误的银行卡号么....
#3 楼 @I_AM_NOT_DHH 重新注册一个
怎么都不现身呢,让我等瞻仰一下~
用腾讯的企业邮箱发信完事
html5 或者 flash
哈哈 不错的海报!
我靠,想搞基啊~
怎么又拿语言和框架比,你应该说 Rails 和 CakePHP 吧? 只看标题没看链接
minitest 如何?
Oh, 6+ years...
好人一生平安
# coding: utf-8
class Message
include Mongoid::Document
include Mongoid::Timestamps::Created
include Mongoid::CounterCache
include Mongoid::DelayedDocument
field :content
field :sender_id
field :receiver_id
field :readed, :type => Boolean, :default => false
embedded_in :dialog
counter_cache :name => :dialog, :inverse_of => :messages
belongs_to :sender, :class_name => 'User', :foreign_key => 'sender_id'
belongs_to :receiver, :class_name => 'User', :foreign_key => 'receiver_id'
validates :content, :presence => true, :length => { :maximum => 140 }
index :receiver_id => 1
index :created_at => -1
default_scope desc('created_at')
# A little confused.
def self.post(sender_id, receiver_id, content)
return if sender_id == receiver_id
other_dialog = Dialog.find_or_create_by(:from_user_id => receiver_id, :to_user_id => sender_id)
params = { :content => content, :sender_id => sender_id, :receiver_id => receiver_id }
other_dialog.messages.create(params)
self.perform_async(:send_message_to_self, params)
end
def self.send_message_to_self(opts)
self_dialog = Dialog.find_or_create_by(:from_user_id => opts['sender_id'], :to_user_id => opts['receiver_id'])
self_dialog.messages.create(opts)
User.where(:_id => opts['receiver_id']).first.inc(:messages_count, 1)
end
after_create do
self.dialog.update_attributes(
:last_reply_user_id => self.sender_id,
:last_reply_user_login => self.sender.login,
:last_reply_content => self.content,
:updated_at => self.created_at
)
end
end
ruby_exam.results.includes(:user).order('results.score DESC').collect{ |result| result.user }