class User < ActiveRecord::Base end class Post < ActiveRecord::Base end
module A #TODO # add a method like virtual_id # this virtual_id find the last record in db and add 1
end
class ActiveRecord::Base include A end
user = User.new user.virtual_id = user.id should be User.last.id.suc post = Post.new post.virtual_id = post.id should be Post.last.id.suc 加入数据库最后一条的 id 是“post-orichi-142” 那么 virtual_id 应该是“post-orichi-143” 怎么在 module A 里定义方法 virtual_id, 使得 user 和 post 可以获取一个虚拟的 id