• 有潜力。👍 假以时日,如果有优秀的团队或是“师傅”磨练,将成大气。:D

  • #7 楼 @xstmjh 之前看过,挺糟的。

    最简单的“偷窥”方式就是看 controller:

    https://github.com/discourse/discourse/blob/af96ef2994c5aa26345727fd0bed14e9ffd6cfa0/app/controllers/posts_controller.rb#L61-L107

    def update
      params.require(:post)
    
      post = Post.where(id: params[:id]).first
      post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
      guardian.ensure_can_edit!(post)
    
      # to stay consistent with the create api,
      # we should allow for title changes and category changes here
      # we should also move all of this to a post updater.
      if post.post_number == 1 && (params[:title] || params[:post][:category])
        post.topic.title = params[:title] if params[:title]
        Topic.transaction do
          post.topic.change_category(params[:post][:category])
          post.topic.save
        end
    
        if post.topic.errors.present?
          render_json_error(post.topic)
          return
        end
      end
    
      revisor = PostRevisor.new(post)
      if revisor.revise!(current_user, params[:post][:raw])
        TopicLink.extract_from(post)
      end
    
    
      if post.errors.present?
        render_json_error(post)
        return
      end
    
      post_serializer = PostSerializer.new(post, scope: guardian, root: false)
      post_serializer.draft_sequence = DraftSequence.current(current_user, post.topic.draft_key)
      link_counts = TopicLink.counts_for(guardian,post.topic, [post])
      post_serializer.single_post_link_counts = link_counts[post.id] if link_counts.present?
      post_serializer.topic_slug = post.topic.slug if post.topic.present?
    
      result = {post: post_serializer.as_json}
      if revisor.category_changed.present?
        result[:category] = BasicCategorySerializer.new(revisor.category_changed, scope: guardian, root: false).as_json
      end
    
      render_json_dump(result)
    end
    

    😱 😱 😱

  • #20 楼 @zhangjinzhu 啊 原来是放在一个文件里了,眼花没看见。。。老了老了。。。T__T

  • #17 楼 @zhangjinzhu 我指的是你的代码没有测试啊 =.=

  • 测。。。试。。。咧。。。 😱

  • 删掉 :trollface:

  • #15 楼 @jarorwar SimpleCov

    观察测试覆盖率的意义不是太大,仅仅只能找出哪里忘了测试而已……

  • 开源的 rails 项目我至今没找到质量高的,包括我自己的 angel_nest 在内。:(

  • 最重要的是如何写有效的测试,去年我的 RubyConf China 演讲里有稍微提到一点点。

    我们团队的项目——

    $ rake stats
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Decorators           |    71 |    60 |       3 |      10 |   3 |     4 |
    | Entities             |  1181 |   984 |      31 |      44 |   1 |    20 |
    | Inputs               |    14 |    10 |       1 |       1 |   1 |     8 |
    | Presenters           |   467 |   420 |      21 |      30 |   1 |    12 |
    | Repositories         |   352 |   301 |      24 |       1 |   0 |   299 |
    | Services             |   738 |   589 |      38 |      59 |   1 |     7 |
    | Uploaders            |    55 |    13 |       1 |       3 |   3 |     2 |
    | Validators           |   149 |   128 |       7 |      16 |   2 |     6 |
    | Controllers          |   937 |   766 |      28 |     121 |   4 |     4 |
    | Helpers              |    85 |    68 |       0 |      18 |   0 |     1 |
    | Models               |   531 |   420 |      35 |      35 |   1 |    10 |
    | Mailers              |     0 |     0 |       0 |       0 |   0 |     0 |
    | Javascripts          |   351 |   258 |       0 |      73 |   0 |     1 |
    | Libraries            |  1042 |   860 |      31 |     110 |   3 |     5 |
    | Controller specs     |   559 |   460 |       0 |       0 |   0 |     0 |
    | Decorator specs      |    14 |    10 |       0 |       0 |   0 |     0 |
    | Entity specs         |   539 |   430 |       0 |       5 |   0 |    84 |
    | Helper specs         |    36 |    29 |       0 |       0 |   0 |     0 |
    | Lib specs            |    85 |    69 |       0 |       0 |   0 |     0 |
    | Model specs          |   124 |    95 |       3 |       0 |   0 |     0 |
    | Presenter specs      |   248 |   190 |       0 |       0 |   0 |     0 |
    | Routing specs        |     8 |     7 |       0 |       0 |   0 |     0 |
    | Service specs        |   599 |   487 |       3 |       2 |   0 |   241 |
    | Validator specs      |   269 |   210 |       1 |       3 |   3 |    68 |
    | Javascript specs     |   148 |   102 |       0 |      34 |   0 |     1 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Total                |  8602 |  6966 |     227 |     565 |   2 |    10 |
    +----------------------+-------+-------+---------+---------+-----+-------+
      Code LOC: 4979     Test LOC: 1987     Code to Test Ratio: 1:0.4
    

  • 有 Hacker News 帐号的同学如果觉得这篇博文有点点用处的话欢迎 upvote 喔。:)

  • #5 楼 @zgm 没买到直飞的机票,所以今年不来了…… 期待明年。:)

  • #10 楼 @jiyinyiyong 真正开始写代码是高中毕业后了…… T_T

  • 这类事件近几年在西方世界频繁发生,所以很多人都提高了对这类事件的重视度。包括前阵子的某大会 promo 时拿女生当作“好处”的(perk)。

    RubyChina 论坛上我观察到有几次情况差不多的招聘贴,果断皱眉并无视了——貌似大部分国内的程序员对这方面还没有足够的认识。

  • 97 年开始摸电脑,当时还不知道如何正常关机。 97 年开始接触 BBS,“上海热线”之类的服务。 97 年开始自学做网页(好像是从“计算机硬件”之类的杂志里看到的)。 97 年初中还未毕业,出国来澳大利亚。 00 年回国,念高中。 00 年开始给各大计算机杂志撰稿,被当时的“未来数码动力”网站聘用。都是数码硬件相关,与程序和软件完全沾不上边。 01 年开始自己做网站。当时还不会写程序,视程序员为神。算是第一次“创业” 02 年开始把玩 Linux/BSD 兼 sysadmin(贩售虚拟主机),算是第二次“创业”。 04 年高中毕业后再次出国来澳大利亚,念多媒体专科,第一次开始学写程序(第一门语言 JavaScript,第二们语言 PHP)。 06 年开始 IT/多媒体本科。短暂的接触了 Assembly。 06 年获得第一份兼职的程序员工作(HTML/CSS/JS/PHP)。 06 年开始搭建自己的 blog 网站(Wordpress)。 07 年开始 freelance,程序与网站设计兼顾。 08 年本科毕业,获得第一份全职的程序员工作(仍然是 HTML/CSS/JS/PHP)。 10 年开始从 PHP 转向 Ruby(当时在 Envato 任职)。 10 年开始给 Rails 项目做贡献。 11 年开始带队(当时在 SitePoint 任职)。 13 年继续在带队。

    比起从小就摸电脑写程序的,我算是半路出家,后起步的。所以,如果你觉得你起步的晚,看看我就可以啦!:D

  • Windows phone, Android 和 iPhone 都有的低调飘过…… =.=

  • class Person
      def hello
        yield
      end
    
      def world(&proc)
        proc.call
      end
    
      def haha(&block)
        instance_exec(&block)
      end
    end
    
    p = Person.new
    p.hello {puts self.class}
    p.world {puts self.class}
    p.instance_eval {puts self.class}
    p.haha {puts self.class}
    
    Object
    Object
    Person
    Person
    
  • RSpec 如果 use_transactional_fixtures = true 的话,after_commit 不会被执行。

  • gem 怎么升级某个 at September 16, 2013

    即便用 gem update cocoapods 也不一定能保证可以更新到新版本。唯一的方法是在 Gemfile 里指定版本。

  • #53 楼 @ckf513728912 这个方面的我不太熟悉哎不好意思……

  • Writing Sensible Tests for Happiness at September 10, 2013

    let 都是 lazy-evaluated 的,所以当程序执行到 user 的时候 let(:user) 才会被赋值。

  • #1 楼 @aptx4869 直接 export 就可以了不需要重新编译。如果没有明显区别的话可以尝试修改一下参数。根据系统和内存的区别,也许提升不了了。

  • 看美剧 ^___^

  • 赞!

    Cells 的作者 Nick Sutterer 今年在 RubyConf India 做的演讲中提及了 Cells。演讲里还有提及 Datamappify 哟!;)

  • 以后都是 test suite running... -__,-

  • 其实归根结底还是 基数大 的问题。

    在袋鼠国,优秀的人才其实也不算多——我们公司现在还在招聘,已经几个月了还没有找到如意的人选,其间在 code test 这段被我拒掉的已经好几十人了。

    “不思进取”的开发者到处都是,只是在国外的话,一般不那么明显,因为他们不会出现在技术社区…… 在国内的话由于东西方文化的不同,大家都喜欢泡在网上,于是技术论坛上就会出现很多奇奇怪怪的帖子……

  • Fly Vim, First - Class at August 30, 2013

    我用的 Janus :)