Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Rei
@Rei
管理员
第 1 位会员 / 2011-10-28

[email protected]
深圳
186 篇帖子 / 9147 条回帖
730 关注者
0 正在关注
11 收藏
中下水平 Rails 程序员
打赏作者
GitHub Public Repos
  • writings 941

    [Closed] Source code of writings.io

  • alipay 732

    Unofficial alipay ruby gem

  • code_campo 291

    [Closed] Source code of http://codecampo.com

  • asciidoctor-pdf-cjk-ka... 101

    **no longer maintained**

  • asciidoctor-htmlbook 31

    Asciidoctor HTMLBook is an Asciidoctor backend for converting AsciiDoc documents to HTMLBook docu...

  • material-ui 17

  • htmlrenderer 12

  • rich-text-editor 12

  • rails-chatgpt-demo 8

  • rails-app 7

    A Rails project template lets me start new projects quickly.

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 我觉得 “头条” 栏目没有什么用 at 2017年07月24日

    赞成

  • Rails 5.1.1 新特性 [添加新的加密的 secret] 示例 at 2017年07月24日

    不打算使用。

  • 额,问个知道结果但不知道原因的问题,勿怪。。。 at 2017年07月24日

    如果我维护这段代码第一反应会是我艹。这就是一段没有文档的 DSL,只有写的人觉得爽,后人没法维护。

  • [译] 关于 RSpec 的一点方法总结 at 2017年07月23日

    Rspec 难写难读,读的时候要把每层 context 的 before 和 let 都看一遍,才知道 case 的上下文是什么。

    Minitest 是 plain Ruby,Ruby 的代码规范、重构方法、抽象逻辑都适用,懂得写好 Ruby 的也就懂得写好 Minitest。这也就是为什么 Rspec 的文章比 Minitest 多那么多,其实是 Rspec 里面乱七八糟的东西太多了。

  • [译] 关于 RSpec 的一点方法总结 at 2017年07月23日

    Minitest 不推崇不必要的抽象。

  • HTTP 请求会被浏览器和服务器之外的其他地方缓存吗? at 2017年07月23日

    It depends... https://tools.ietf.org/html/rfc7234

  • [译] 关于 RSpec 的一点方法总结 at 2017年07月23日

    Rspec 可以让测试代码快速膨胀。

  • 额,问个知道结果但不知道原因的问题,勿怪。。。 at 2017年07月22日

    可以,没什么问题。

  • Model 中 validates 的验证可以设置只在特定动作里执行吗? at 2017年07月22日

    并不会,我贴下完整代码:

    # File activemodel/lib/active_model/secure_password.rb, line 53
    def has_secure_password(options = {})
      # Load bcrypt gem only when has_secure_password is used.
      # This is to avoid ActiveModel (and by extension the entire framework)
      # being dependent on a binary library.
      begin
        require "bcrypt"
      rescue LoadError
        $stderr.puts "You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install"
        raise
      end
    
      include InstanceMethodsOnActivation
    
      if options.fetch(:validations, true)
        include ActiveModel::Validations
    
        # This ensures the model has a password by checking whether the password_digest
        # is present, so that this works with both new and existing records. However,
        # when there is an error, the message is added to the password attribute instead
        # so that the error message will make sense to the end-user.
        validate do |record|
          record.errors.add(:password, :blank) unless record.password_digest.present?
        end
    
        validates_length_of :password, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED
        validates_confirmation_of :password, allow_blank: true
      end
    end
    

    这一行:

    record.errors.add(:password, :blank) unless record.password_digest.present?
    

    如果 password_digest 不存在,就会报 password 为空,这样创建用户的时候校验通不过。

  • Model 中 validates 的验证可以设置只在特定动作里执行吗? at 2017年07月22日

    源码:

    validates_confirmation_of :password, allow_blank: true
    

    如果 password 为空就不校验,所以你不要传 password 参数(去掉表单项)就行。

  • Ruby 作用域问题,应该如何访问域外的实例方法 at 2017年07月22日

    你的问题可以简化为:

    class A
      def a_method
        "call from a"
      end
    end
    
    class B
      def b_method
        a_method
      end
    end
    

    B 定义在 A 里面和外面对于实例方法并没有什么不同——实例方法需要通过实例调用。

    想要用 B 调用 A 的方法,那么 new 一个实例:

    class B
      def b_method
        A.new.a_method
      end
    end
    
  • Ruby 作用域问题,应该如何访问域外的实例方法 at 2017年07月22日

    奥,你定义了自己的 Ruby 语法。这个语法在 MRI 里不能执行,也许自己写一个解释器可以。

  • Ruby 作用域问题,应该如何访问域外的实例方法 at 2017年07月22日

    你提问都说了“跨作用域”,跨作用域当然是不能访问拉。

  • Ruby 作用域问题,应该如何访问域外的实例方法 at 2017年07月22日

    X-Y Problem http://coolshell.cn/articles/10804.html

  • 调查一下论坛上用 Linux 的桌面环境 at 2017年07月21日

    楼主已匿

  • 招募项目合伙人 at 2017年07月21日

    这里不容忍人身攻击,早几十楼就应该封了。

  • Rack BUFSIZE 导致大文件上传很慢 at 2017年07月19日

    大文件直传云储存。

  • 我觉的 Ruby China 对新手不太友好 at 2017年07月18日

    很多人还是搞不懂关键在于“提问的方式”而不是“问题的深浅”。

    说 StackOverflow 好的有看过 StackOverflow 的提问须知吗?

    不要拿用功的提问者和热心的回答者的劳动成果当作自己伸手的理由,你可以去 StackOverflow 提问试试。

    StackOverflow 的功能和运营都很好,他们有一个机制让高阶用户帮初学者纠正提问(或者 -1),Ruby China 是纯自发组织,没有那么多精力。我能做的就是把提问的智慧再一次挂在显眼位置 https://ruby-china.org/topics/24325

    如果还是不理解,我想社区和业界都不会有什么损失,损失的只有提问者自己。

  • 最近写了个京东支付的 gem,欢迎 mark. at 2017年07月18日

    赞,提点建议:

    1. github repo name 应该和 gem name 一致
    2. alipay gem 新接口会使用实例,在对象语言里显得比较自然 https://github.com/chloerei/alipay/tree/openapi
  • 请教大家 rubypython 如何 使用 From…import at 2017年07月18日

    楼主讲的是这个 https://github.com/halostatue/rubypython

  • 安装好 Ruby 和 RubyGem 后无法用 gem 命令线上下载 Rack 和 Rails 等 gem 包 at 2017年07月18日

    那么你要怀疑证书是不是真的有问题了:本地证书没更新、翻墙管道用了假证书、VPS 服务商替换了假证书……

  • 安装好 Ruby 和 RubyGem 后无法用 gem 命令线上下载 Rack 和 Rails 等 gem 包 at 2017年07月18日
    1. 翻墙解决网络问题
    2. ubuntu 16.04 源里 ruby 版本是 2.3,没特别需求就用这个,不用 rvm
  • 如何读文档? at 2017年07月17日

    我希望大家先做好 CRUD 程序员。

  • 话说 Rails Guide 中文的那个域名已经不用了吗? at 2017年07月14日

    不用了,https 设置有冲突。

  • 验证支付宝回调时踩过的坑 at 2017年07月14日

    一个 demo https://github.com/chloerei/alipay-demo

  • 我觉的 Ruby China 对新手不太友好 at 2017年07月13日

    该不该用 devise 没有一个共识 https://ruby-china.org/topics/15738

  • 关于 alipay 的问题 at 2017年07月13日

    在 ruby 里面要把支付宝公钥加上换行,每行长度参考自己的公钥。

  • 关于 alipay 的问题 at 2017年07月11日

    https://doc.open.alipay.com/

  • 关于 alipay 的问题 at 2017年07月11日

    Alipay::Client

  • 关于 alipay 的问题 at 2017年07月11日

    现在接入就用新的了,还有沙盒环境。楼主密钥已泄漏,记得换一个。

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