Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
@chuanjiabao
VIP
NO. 3981 / 2012-10-09

7 Topics / 12 Replies
1 Followers
3 Following
3 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 寻求前后端兼职 (HTML\Ruby\Python\PHP) at March 15, 2016

    每周能投入几天 @chareice

  • 如何在源码阶段写出更快的 Ruby at May 27, 2015

    谢谢分享!!

  • 那位大侠可以推荐一个 jq 的插件,可以达到类似于 taobao 首页左侧栏目的导航效果? at April 17, 2014

    #1 楼 @ichord 非常感谢!

  • Newrelic 监控的 response 时间 和实际测试时间 差别很大。 at July 28, 2013

    #3 楼 @watgon 3x

  • Newrelic 监控的 response 时间 和实际测试时间 差别很大。 at July 24, 2013

    #1 楼 @huacnlee 应该不是。 可能是我测试的时候并发数很高(100)导致的(rails,只开了 4 个进程)。 从 siege 来看,响应是很高的,因为大多数在排队。 从 newrelic 来看,响应不高,因为每个都很快被处理了。

  • FactoryGirl 创建 has_one 关系! at April 10, 2013

    问题的原因是由于 activerecord 的 cache 导致的。 我把出问题相关的代码都贴出来:

    #issue.rb
    class Issue < ActiveRecord::Base
        has_one  :resolve,:dependent => :destroy
        before_create :issue_opened_action
    
        def issue_opened_action
            self.resolve.destroy unless self.resolve.nil?
        end
    
    #resolve.rb
    class Resolve < ActiveRecord::Base
        belongs_to :issue
    end
    
    #Factories.rb
    FactoryGirl.define do
      factory :issue do
        factory :issue_with_resolve do
            after(:create) do |issue|
                FactoryGirl.create(:resolve,issue: issue)
            end 
        end
      end
    

    罪魁祸首就是 issue_opened_action。 由于 issue 创建完成前调用了 issue_opened_action,此时并没有 resovle 和 issue 关联,所以 issue.resolve 一定为 nil,activerecord 把此值加入 cache,后续即便是创建关联的 resolve,issue.resolve 返回的还是 cache 中的 nil,除非 reload 或者通过 inverse_of.

  • Rspec + FactoryGirl + i18n=cn + model.valid? == false 的时候如何给出明确的 cn 提示 at March 26, 2013

    #7 楼 @nightire >>>想 FG 的开发者应该不会不知道这一点,现在的结果应该是权衡之后的选择。 这个观点我不认同。 首先,在 en 模式下,fg 就会把所有的信息都输出出来,为什么在 cn 模式下就要"权衡"呢? 其次,case 没通过,给出明确的信息应该是友好的,和”更细力度的测试“没啥关系吧。

  • Rspec + FactoryGirl + i18n=cn + model.valid? == false 的时候如何给出明确的 cn 提示 at March 26, 2013

    #5 楼 @nightire 可能是我表述的问题,我和你说的不是同一件事。我说的是对于这样一个 case it {should be_valid} 如果没有通过,应该自动告诉我 model 中哪个字段错误了,不要自己在写代码了输出这些错误了

  • Rspec + FactoryGirl + i18n=cn + model.valid? == false 的时候如何给出明确的 cn 提示 at March 26, 2013

    #3 楼 @nightire 是不是和版本有关。我用的 4.04。

  • Rspec + FactoryGirl + i18n=cn + model.valid? == false 的时候如何给出明确的 cn 提示 at March 26, 2013

    #1 楼 @nightire 中文化已经做了。 关键是如下 case: model 有 10 个字段,其中 8 个不符合 valid 的。如果不加优化,在 local=cn 仅会有提示此 model 不合法,不会给出那 8 个字段出错,哪些出错;但是在 local=en 的模式下会给出哪些字段出错,什么地方错了。

    这个是 factory girl 的问题。

关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English