Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Cantin
@cantin
高级会员
第 353 位会员 / 2011-12-01

广州
3 篇帖子 / 213 条回帖
1 关注者
0 正在关注
3 收藏
GitHub Public Repos
  • dotfiles 2

  • mtouch 2

  • cantin.github.com 1

    cantin's blog

  • cap_deployer 1

    cap deploy helper

  • d-render.js 1

    A lightweight hotwired-compatible lib with directive programming in HTML

  • merit 1

    Reputation system Rails engine.

  • floatThead 1

    Fixed table headers, without custom html/css

  • shu 1

    something just for practice

  • vim-closer 0

    Closes brackets

  • animegan2-pytorch 0

    PyTorch implementation of AnimeGANv2

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 巨坑爹的 String#gsub 方法 at 2013年07月19日

    楼主是想吐槽 replacement 里面有 special match chars 是吗 不过 API 都已经明确说明了这些情况了 http://ruby-doc.org/core-1.9.3/String.html#method-i-gsub

  • 巨坑爹的 String#gsub 方法 at 2013年07月19日
    1.9.3p429 :045 > '\&'
     => "\\&"
    
    1.9.3p429 :026 > 'asd'.gsub('d', '<\&>')
     => "as<d>"
    
    1.9.3p429 :047 > 'asd'.gsub('d', "<\\&>")
     => "as<d>"
    
    
    
  • 关于中文字符问题 at 2013年07月10日
    -K kcode Specifies KANJI (Japanese) encoding. The default value for script encodings (__ENCODING__) and external encodings (Encoding.default_external) will be the specified one. kcode can be one of
     e       EUC-JP
     s       Windows-31J (CP932)
     u       UTF-8
     n       ASCII-8BIT (BINARY)
    

    ruby1.9 直接在文件头

    #encoding: utf-8
    

    就可以处理中文了

  • symbol 可以使用变量作为键不? at 2013年06月26日
    symbol = 'name'
    hash[symbol.to_sym] = 'test'
    
  • Discourse 中文完全安装指南 at 2013年05月22日

    https://github.com/discourse/discourse/blob/519bec6b04046b0f4da3b782d2ccb756a8514d48/docs/INSTALL-ubuntu.md

  • rails 的 any? 的奇怪问题 at 2013年05月22日
    puts 'hi' if 0
    
  • 关于 devise 使用中出现的 ArgumentError at 2013年05月17日

    那个 blog 是 10 年的,你要看的话应该看https://github.com/plataformatec/devise generator 只是 copy 了 devise 的 view 到你项目里面

    另外 ArgumentError 明显是 method 方法的异常,应该首先去查 form_for 的文档 rails 2 中的 form_for 的参数是 form_for(record_or_name_or_array, *args, &proc) 所以上面的写法应该是 rails 2 的

  • 关于 devise 使用中出现的 ArgumentError at 2013年05月17日

    form_for 是只有两个参数的

    form_for(record, options = {}, &block)
    

    devise 的 view 也是这么写的 https://github.com/plataformatec/devise/blob/master/app/views/devise/confirmations/new.html.erb#L3

    你的 form_for(resource_name, resource, :url => confirmation_path(resource_name)) 是哪里来的?

  • [广州] 广州网易招聘 Ruby 程序员 at 2013年05月14日

    #8 楼 @hebe_he 直接过来就好了 免费

  • rails 浏览器 问题 at 2013年05月13日

    #2 楼 @liker 刚才看反了 这个用 jquery-ujs(rails 自带的)实现比较好,你的实现少了 authenticity_token,会被 reset_seesion 的(默认情况下) 另外这种是前端的错误,你应该像一楼所说的那样用 firebug 去调试

  • rails 浏览器 问题 at 2013年05月13日

    你的 chrome 确定是 ajax 提交的?

  • 自己写的类中怎么调用 form_tag at 2013年05月13日

    ApplicationController.helpers.form_tag

  • 如何修改 Rails 中的配置变量 如 asset_host at 2013年05月12日

    你的 gem 是 engine?

    你可以在 initializers/里面调用 Gem 的方法取得你要的值 赋给 Rails.application.config.asset_host(没试过,应该可以)

    如果要写入 engine 里面, 在 engine/lib/engine_name.rb 里写个 initializer hook

    class Engine < ::Rails::Engine
      initializer :assets do |config|
           Rails.application.config.assets_host = SomeClass.some_method
      end 
    end
    
  • 如何修改 Rails 中的配置变量 如 asset_host at 2013年05月12日

    https://github.com/rails/rails/blob/master/railties/lib/rails/application.rb#L33

  • Ruby 能够 include 一个模块在另外某个模块之前或者之后吗? at 2013年05月06日

    #9 楼 @iBachue 这个是 self.included 是 hook 方法,它在 A include 进来后就会执行。这也是为什么要在 A 写这个方法而不是在 B 写

  • Ruby 能够 include 一个模块在另外某个模块之前或者之后吗? at 2013年05月06日
    module A
      def self.included(base)
        if base == F
          base.send :include, E
        end
      end
    end
    
  • 如何建立 n*n 的 2 维数组 / 矩阵 at 2013年04月13日

    gets 得到的 String,不是 Numeric

    a = Matrix.zero(n.to_i).to_a
    
  • <<Ruby 元编程>>中的类宏怎么理解,还有帮忙解释下书中这段代码的执行过程。 at 2013年03月14日

    1)实例化的时候没有调用上面的方法,但是在定义 Book 这个类是已经执行了这些方法

     deprecate(:GetTitle, :title)
    ...
    

    2)LEND_TO_USER 是通过 deprecate :LEND_TO_USER, :lend_to 在定义这个类时一起定义出来的。具体可以看 define_method 这个方法

    类宏我觉得应该是在定义类时执行的代码,如 deprecate(:GetTitle, :title),最简单的是

    class A
      puts 'hello'
    end
    

    拟态方法不知道是什么,建议读原版书。

  • Google Reader 即将关闭,你有什么想说的? at 2013年03月14日

    http://keepgooglereader.com/ 已经有人在行动了

  • 怎么禁用 Rails 视图中的 HTML 自动转换?表达的有点不好。。 at 2013年03月12日

    http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/

  • 请教关于 assets 如何只包含必要的 js at 2013年03月10日

    http://guides.ruby-china.org/asset_pipeline.html

  • Rails 2.3 的开发 git 库在哪里? at 2013年03月08日

    https://github.com/rails/rails/tree/2-3-stable

  • 求推荐读取 excel 的 xlsx 文件的 gem at 2013年02月19日

    https://github.com/hmcgowan/roo

  • rails 使用生成的 destroy 方法时,为什么同时还会将 session 中的数据销毁了? at 2013年02月06日
    = csrf_meta_tags
    

    在你自定义的 layout 中加入这个,csrf 可以去看 rails guides 的安全那一章

  • rails 使用生成的 destroy 方法时,为什么同时还会将 session 中的数据销毁了? at 2013年02月03日

    那条记录删除成功?

  • [rspec] controller spec 的一个 example 里前后两个 request, 后者使用了前者的 params at 2013年02月03日

    另外

    post :create content: 'Lorem lipsm'
    

    不是少了个,吗

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