Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
2622
@jjym
高级会员
第 2622 位会员 / 2012-06-22

[email protected]
上海
26 篇帖子 / 1077 条回帖
24 关注者
0 正在关注
118 收藏
GitHub Public Repos
  • hdwallet 34

    HD wallet BIP-32 related key derivation utilities.

  • buddy-alloc 31

    Buddy-alloc is a memory allocator for no-std Rust, used for embedded environments.

  • minimal-ray-tracer-zig 2

  • godwoken 1

  • ckb-std 1

    This library contains serveral modules that could help you write CKB contract with Rust.

  • fiber-autopilot 0

  • ckb-cli 0

    CKB command line interface

  • vulkan-tutorial-c 0

    Learn https://vulkan-tutorial.com/Introduction with C

  • test-bincode 0

  • force-bridge 0

    General Force Bridge components.

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 你们用什么缓存?rails 自带的缓存 page,action,fragment 是不是不大方便用啊? at 2012年08月17日

    fragment 感觉良好

  • 源码中 ActiveRelation::Base 的 all 方法 (?) 定义在哪里??? at 2012年08月17日

    #13 楼 @hhuai 我这 3.2.3 和 3.2.8 都是 all。github 上也是 all...

  • 源码中 ActiveRelation::Base 的 all 方法 (?) 定义在哪里??? at 2012年08月16日

    #11 楼 @hhuai

    这个是 Relation 的我知道 AR::Base 是在哪里定义或 include 的真心找不到。。

  • Windows 8 对 Ruby 的支持 at 2012年08月16日

    是 ruby 对 win8 支持的支持才对吧。。

  • validates 验证中的错误信息如何自定义 at 2012年08月16日

    validates :name,presence: {message: "不会看示例啊"}

  • 数组对应项相加 at 2012年08月16日

    a1.zip(a2,a3).map{|arr| arr.reduce &:+} 其实 map 这些不还是循环..这么纠结干嘛

  • 源码中 ActiveRelation::Base 的 all 方法 (?) 定义在哪里??? at 2012年08月16日

    @leomao10 正解 relation 中初始化有这个

    relation.rb
    def initialize(klass, table, values = {})
          @klass             = klass
          @table             = table
          @values            = values
          @implicit_readonly = nil
          @loaded            = false
          @default_scoped    = false
        end
    

    这个是 relation include 的 delegate 模块中的代码

    def method_missing(method, *args, &block)
          if @klass.respond_to?(method)
            ::ActiveRecord::Delegation.delegate_to_scoped_klass(method)
            scoping { @klass.send(method, *args, &block) }
          elsif Array.method_defined?(method)
            ::ActiveRecord::Delegation.delegate method, :to => :to_a
            to_a.send(method, *args, &block)
          elsif arel.respond_to?(method)
            ::ActiveRecord::Delegation.delegate method, :to => :arel
            arel.send(method, *args, &block)
          else
            super
          end
        end
    

    这个是 Base include 的 core 模块的代码,其中传了 self 作为 Relation 实例的 klass 并且,relation 在 method_missing 中调用,这样可以解释为何只在 Base 里 include 模块即可

    def relation #:nodoc:
            relation = Relation.new(self, arel_table)
    
            if finder_needs_type_condition?
              relation.where(type_condition).create_with(inheritance_column.to_sym => sti_name)
            else
              relation
            end
          end
    

    但是有个很严重的问题!!!我找了一下午不知道 relaiton 是在哪里调用的!! Base 的查询方法都在 querying 中

    delegate :find, :take, :take!, :first, :first!, :last, :last!, :exists?, :any?, :many?, :to => :all
        delegate :first_or_create, :first_or_create!, :first_or_initialize, :to => :all
        delegate :find_by, :find_by!, :to => :all
        delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, :to => :all
        delegate :find_each, :find_in_batches, :to => :all
        delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins,
                 :where, :preload, :eager_load, :includes, :from, :lock, :readonly,
                 :having, :create_with, :uniq, :references, :none, :to => :all
        delegate :count, :average, :minimum, :maximum, :sum, :calculate, :pluck, :ids, :to => :all
    

    但是我怎么找都找不到 all 在哪里,用屁股想的话会知道 all 内调用了 relation 方法,但是我想看 all 的代码,却找不到他定义在哪里!求各位看过这里源码的指导下!

  • 源码中 ActiveRelation::Base 的 all 方法 (?) 定义在哪里??? at 2012年08月16日

    好吧,我表达能力有问题,我是想问为什么 AR::Relation 中可以调用 page 方法?因为我没有找到 AR::Relation 在哪里 include 模块了 我知道调用 page 这个 scope 后的 Relation 会 extending 模块 但是比如 User.where(xx).page 这个是怎么做到的??

  • 源码中 ActiveRelation::Base 的 all 方法 (?) 定义在哪里??? at 2012年08月16日

    又检查了下,好像和 ActiveRecord 的延迟执行有关,应该 page 最后还是在 AR::Base 上调用的,所以 AR::Relation 可以不定义。看源码求证下...

  • 源码中 ActiveRelation::Base 的 all 方法 (?) 定义在哪里??? at 2012年08月16日

    不知道我理解错你们的意思了,还是你们理解错我的意思了

    我是找不到 AR::Relation 在哪里 include

  • 做个小调查,读过 Rails 源码的举一下手。 at 2012年08月15日

    @outman @cantin 这个真有意思。。。

  • 请问这两个的区别是什么? at 2012年08月15日

    #6 楼 @hooopo 就是说如果有需要:article_id 还要再来个?

  • 请教一个新手是否应该选择 Ruby 的疑惑 (与 ASP.NET MVC 比较)。 at 2012年08月15日

    想学就学,别人说的没用

  • 请问这两个的区别是什么? at 2012年08月15日

    对索引不了解。。借此地问下第一种索引对查单个字段有助吗?比如 where:article_id?还是说和具体数据库有关?我只知道 mongo 好像这种组合索引对单个没用,还要建单个的索引

  • 有人觉得 Ruby 的语法乱吗? at 2012年08月15日

    为什么都 10L 了还没人吐槽

    这里为啥不可以 nd.name = "Benzy"? puts nd.name 好多地方啊,又是 do .... end, 又是 begin ....end,搞得跟 pascal 语法差不多了。 为啥不能直接{}呢? 没有 return 这个关键词 ...

  • 有人觉得 Ruby 的语法乱吗? at 2012年08月15日

    #3 楼 @nevernet 哪里有 js 和 java 的影子了? .net 那个是 rails 的影子

  • 有人觉得 Ruby 的语法乱吗? at 2012年08月15日

    感觉你学的 Ruby 和我们学的不是一个次元的。。

  • 想买一本关于 Ruby 基础的书 at 2012年08月15日

    Ruby 编程语言?

  • [北京][2012年08月11日] Ruby 活动公告 + 媒体资料 + 小结 at 2012年08月11日

    @blackanger 很多人对这个题目都感兴趣,加油下次再上

  • 有没有简单的方式给 lazyload 出来的元素绑定上 js 的事件? at 2012年08月08日

    土鳖的问下 lazyload 是咋 load 来的。。?能不能 onclick 什么的?不一定要纠结 jq 的事件绑定。

  • SecureRandom 生成内容的唯一性? at 2012年08月07日

    根据 rails tutorial 上面说的,这个概率是小到了多少多少分之一。重复了算你运气好。不过再加个时间戳应该很安全了

  • ruby.taobao.org 镜像目前得到了 Rubygems 官方的帮助 at 2012年08月07日

    感觉还是 source 自己改好。本来就是留着改的,自动跳转还不如想办法默认 rails new 直接生成 source=taobao 的 Gemfile 好些,把简单问题复杂化了

  • 用 Taobao 的 gem 源也会被强么? at 2012年08月07日

    和 LZ 一样情况

  • Ruby 的常量查找路径问题 at 2012年08月07日

    binding 不一样,第一个在 C1 中,第二个在 C1 的 singletonclass 中

  • 好难看的 end at 2012年08月06日

    主要还是习惯,现在看python没end,还有C#等4格缩进各种不习惯

  • 写给大家看的 Rails 部署:第一篇 简单快捷的部署方案 at 2012年08月06日

    支持 LZ,让一个新手部署还是很难的

  • ruby.taobao.org 镜像目前得到了 Rubygems 官方的帮助 at 2012年08月06日

    有个缺点啊。。镜像服务器万一出问题了(像上次那样),那国内全部阵亡。。 感觉还是自己改 source 好点,而且 source 本来就是给你改的吧,这样这个功能反而成鸡肋了

  • Ruby 代码加密工具有哪些? at 2012年08月05日

    混淆器?一般情况下不需要吧

  • 反馈下 ruby-china 手机版 两个小问题 at 2012年08月05日

    是有这 bug。WP7 可以回帖但是点发帖按钮没反应

  • 大家看下这段`ActiveRecord 下 find 方法实现' 的伪码是不是有问题? at 2012年08月03日

    #9 楼 @zw963 这是作者需要的 find 和 joins

    你所谓的真实含义是字面上和 Rails 方法中的 joins

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