恩 你看的没错  
@jasl 3Q
初次看Journey真的有种望而却步的赶脚
不知道大大是如何看源码的 有什么技巧可以分享嘛
@lilijreey 之前看源码的时候就发现这个梗了,不过当时只是想先去了解大致的流程
刚刚去看了一下 Racc 的文档 然后一脸懵逼啊
这边有个例子 HelloRacc
pry + puts(某些情况下 pry 不好用)
楼上正解
不好意思 我来搞破坏了 所以他变成 -1 了 没有恶意,只是想测试一下
正好翻到了这题 从提交的执行时间看 树状数组用的时稍微少了一点,其实和 merge sort 时间复杂度是一样的
def count_smaller(nums)
  idxes = {}
  nums.sort.each_with_index {|v, i| idxes[v] ||= i + 1}
  i_nums = nums.map {|n| idxes[n] }
  ft = FenwickTree.new(nums.size)
  ans = Array.new(nums.size)
  (0..(nums.size-1)).to_a.reverse.each do |i|
    ans[i] = ft.sum(i_nums[i] - 1)
    ft.add(i_nums[i], 1)
  end
  ans
end
class FenwickTree
  attr_accessor :n, :sums
  def initialize(n)
    @n = n
    @sums = Array.new(n + 1) { 0 }
  end
  def add(x, val)
    while x <= n
      sums[x] += val
      x += lowbit(x)
    end
  end
  def lowbit(x)
    x & -x
  end
  def sum(x)
    res = 0
    while x > 0
      res += sums[x]
      x -= lowbit(x)
    end
    res
  end
end
a = {a: 1, b: 2}
a.each { |k, v| a[v] = a[k] } # will raise "can't add a new key into hash during iteration"
a.dup.each { |k, v| a[v] = a[k] } # works
:plus1:
module B
  class Stuff < Base
    has_many :resources, -> (object) { unscope(where: :resourceable_type).where(resourceable_type: object.class.name.split("::").last)) } as: :resourceable
  end
end
可以这样试试
解决 view-model 感觉 presenter 看起来更纯粹 Draper 很好用,也选择了用它,不过也推荐看一下 http://thepugautomatic.com/2014/03/draper/
👍
rspec 在 controller 测试 post get 方法 调用时,怎么设置 headers => rspec when controller test post get method call, how to set headers 把中文用 google 翻译成英文 然后再贴到 google 里搜索 http://stackoverflow.com/questions/9654465/how-to-set-request-headers-in-rspec-request-spec
:plus1:
公司很棒
rubocop 推荐不写 return
感觉可以嵌套一层
支持
很棒,支持了