• sublime 报到

  • 1->7

  • 我是先看的 Tutorial,现在正在看 Agile。

  • 记录删除的处理方法 at January 25, 2014

    #20 楼 @Rei正确,改成以下就通过了。谢谢了,这下不用重新设计成 N-to-N 模式了。

    def destroy
        @user = User.find(params[:id])
        Topic.where(like_ids: @user.id).pull(like_ids: @user.id)
        User.find(params[:id]).destroy
        flash[:success] = "用户成功删除!"
        redirect_to users_path
      end
    
  • 记录删除的处理方法 at January 25, 2014

    #17 楼 @Rei 在 user_controller.rb 中做以下处理,like_ids Array 中的 user.id 还是没有被删除。

    def destroy
        Topic.where(like_ids: params[:id]).pull(like_ids: params[:id])
        User.find(params[:id]).destroy
        flash[:success] = "用户成功删除!"
        redirect_to users_path
      end
    
  • 记录删除的处理方法 at January 25, 2014

    #15 楼 @Yujing_Z谢谢,“ruby-china 没有 找一个用户关注的所有的帖子 这个功能,所以可以这样设计。而很明显你不一样,你有找到一个帖子所有 liked_user 的需求”,这个分析很正确,赞一个!

    决定接受你的建议,重新设计成 N-to-N 模式。

  • 记录删除的处理方法 at January 25, 2014

    #13 楼 @Yujing_Z谢谢,我前面举的例子是省略了的,其实我的设计是 like user 同样需要 reply something 的,你上面提到的多对多设计我也考虑了,不过觉得再加 reply 的时候不好处理,所以才想着仿照 ruby-china 的设计,呵呵,想着是大牛们的设计,肯定有他们的道理。大牛们能出来解答一下就好了。

    我想大概就是因为:Many to many relations require usually double the amount of hits to the database to keep both sides of the relation in sync, since keys are stored on both sides. Due to this they are slower and should be used with caution.

  • 记录删除的处理方法 at January 25, 2014

    #7 楼 @Yujing_Z 谢谢,我是仿照 Ruby-China 论坛的设计,详细请查看 Ruby-China 论坛源码的 Topic model.

    # 回复过的人的 ids 列表
    field :follower_ids, :type => Array, :default => []
    
  • 记录删除的处理方法 at January 25, 2014

    #6 楼 @kgen 谢谢,只是自己的小项目,想知道有没有好的设计方法,避免以后实际项目中犯同样的错误。

  • 记录删除的处理方法 at January 25, 2014

    #3 楼 @blacktulip 我最后采取的方式是在需要读取 ids 的地方做判断,如果是无效 ids 就不显示,同时在 Array 中移出。

  • 记录删除的处理方法 at January 24, 2014

    @dddd1919 谢谢你的建议,比我原来光想着删除的方法好!

  • Rails check_box 的疑问 at January 23, 2014

    #6 @Rei I try the command below in console, same problem. The result message shows "=> true" but the DB record is "1" not true, wired!

    u = User.first =># u.update(delete:"1") =>true User.first =>#

  • Rails check_box 的疑问 at January 23, 2014

    I am sure MongoDB(and/or Mongoid) save "1"/"0" for the check_box, but cannot find an answer for now.

  • Rails check_box 的疑问 at January 22, 2014

    谢谢 Rei,我开始也是这么想的,可能是不是要在 MongoDB 中设置一下,一直找不到答案。

  • Rails check_box 的疑问 at January 22, 2014

    自己想出个苯办法解决一下:

    users_controller.rb

    ... case @user.delete when "1" @user.delete = true when "0" @user.delete = false end @user.save ... 这样可以转换保存为(...,"delete":true...)了,但是觉得很难看,Rails 没有什么内置的方法解决这样的简单问题吗?大家有什么好办法请分享一下,谢谢。

  • 我打电话给腾讯客户服务,他们回答更绝,一定要提供手机号码才能注册(QQ 号码都不能注册),我说我在国外没有手机号码怎么办,发邮件也没人回复,他们说没办法了,政策如此。 感觉他们做大后,不再在意用户的感受。

  • 如何学习 JRuby? at January 11, 2014

    @xds2000 谢谢,目前公司的项目使用 JRuby 开发部署,所以才想快速学习提高。好处是可以一边学习,一边在真实的环境中开发应用。

    谢谢大家,我按照 wiki 的学习指导,目前进度:基本看完 Rails Guide;通过学习 Ruby on Rails Tutorial 实现一个微博客系统,包涵完整的功能 (包括 UI);准备开始看 Agile Web Development with Rails 4 和 Deploying with JRuby。

  • 决定翻译 Rails Guides at January 09, 2014

    有同感,开始先看的 Ruby on Rails Tutorial,跟着书走完一遍,总觉得有些小问题不好办,现在正在看 Rails Guides 英文版,慢慢理顺了一些。

  • Heroku 连接 MongoHQ 的问题 at January 04, 2014

    自己填一下坑,查看了一下 Heroku logs,更新了一下 mongoid.yml,就测试正常了。