Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
@reyesyang
VIP
NO. 25 / 2011-11-01

北京
6 Topics / 328 Replies
4 Followers
1 Following
533 Favorites
Pragmatic Programmer
GitHub Public Repos
  • blog-on-rails 1

    A blog application build with rubyonrails

  • wechat-universal-flatpak 0

    Flatpak 打包微信 Linux Universal 版

  • gnome-shell-extension-... 0

    Adds KStatusNotifierItem support to the Shell

  • xvm 0

    Version Management for more tools

  • LG-ultrafine-brightness 0

    A tool to adjust LG Ultrafine Series Monitor without Bootcamp in Linux and Windows.

  • playground 0

  • parser-study 0

  • spring-boot 0

    Spring Boot

  • clash-core 0

    backup of clash core

  • reyesyang.github.io-so... 0

    Blog source code based on Jekyll 3

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 简单介绍一下 sinatra at April 01, 2014

    #3 楼 @yakczh 我在项目中用这个 Gem,https://github.com/janko-m/sinatra-activerecord

  • 请问有了解 app annie 的么 at March 03, 2014

    听在里面任职的朋友说公司本身业务盈利不错,福利待遇也很好。去过一次,在三里屯 SOHO

  • MRuby 1.0 发布了 at February 28, 2014

    #6 楼 @tumayun http://ruby-china.org/topics/17465

  • Happy Birthday, Ruby! at February 24, 2014

    👍 不过 RVM 上好像还没有更新

  • 键盘符号的中、英、日文的读法 at February 24, 2014

    👍

  • 解析 xml 的 api 接口 at February 23, 2014
    require 'nokogiri'
    
    Nokogiri::XML(xml_str).css('item').each do |item|
      title = item.at_css('title').content
      photo_name = item.at_css('photo_name').content
    end
    

    详细内容参考官方文档 http://nokogiri.org/tutorials

  • irb 中 输入刚用脚手架创建的 post 资源,出现下面的错误!! 弟弟等哥哥们的答案!!!! at February 23, 2014

    你应该是想要 Post 吧

  • spec 测试 edit,update,destory at February 21, 2014

    #2 楼 @u1378130755 会不会是那个对象是你手动创建在 development 环境下的数据库中,而不是在 test 环境下的数据库中

  • 方式参考:好多网页没看?,发到电子书坐地铁时慢慢看 at February 21, 2014

    Pocket

  • 咨询一个 Api 提交数据的格式问题 at January 21, 2014

    我觉得最大的好处就是第一种的参数对调用方而言,构造起来更简单。

  • 关于: 冒号的小问题 at January 21, 2014

    第一种是 ruby1.9 加入的新的 Hash 写法,当 key 为 symbol 类型时,:key => 'value' 可以写成 key: 'value',所以二者是等价的。

  • perform is class method in sidekiq? at January 02, 2014

    perform_async 是类方法,来自于 include Sidekiq::Worker,可参考 https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/worker.rb#L39

    我们定义的 perform 方法是实例方法,是 Sidekiq 将队列中的 job 分配给 Processor 后,在 Processor 中调用的 https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/processor.rb#L49

  • rails_tutorial chapter 10 练习 7: 给输入框添加字数统计。遇到一个奇怪的 bug,求思路。 at January 01, 2014

    http://api.jquery.com/keypress/

    The keypress event is sent to an element when the browser registers keyboard input. This is similar to the keydown event, except that modifier and non-printing keys such as Shift, Esc, and delete trigger keydown events but not keypress events. Other differences between the two events may arise depending on platform and browser.

  • 有关 RVM 不能以 scripts 方式运行 at December 30, 2013

    我的 which rvm 返回的是 /home/reyesyang/.rvm/bin/rvm,所以这个应该是没有问题的。现在使用上有什么问题吗?

  • 支持多音字的汉字转拼音 ruby-pinyin 0.3.0 发布了 at December 30, 2013

    👍

  • 数据恢复了,虚惊一场 at December 26, 2013

    😱

  • 求助 Rails app controller 中 respond 的 csv 格式文件在 win 系统中打开中文为乱码的解决办法 at December 24, 2013

    #9 楼 @luikore Cool,学习了

  • 求助 Rails app controller 中 respond 的 csv 格式文件在 win 系统中打开中文为乱码的解决办法 at December 24, 2013

    Windows 默认使用的 GBK 编码。可以判断 UA,如果是 window 用户,导出时使用 iconv 转成 GBK 编码

    def conv2gbk_if_win(str)
      if request.headers["HTTP_USER_AGENT"] =~ /Windows/
        require 'iconv'
        Iconv.new("GBK", "UTF-8").iconv(str)
      else
        str
      end
    end
    
  • 跟着 rails tutorial 学习时的问题。未知属性 box-sizing 。声明被丢弃 at December 24, 2013

    你确定“本地开发环境表面上看起来正常”吗?

  • 如何理解 Ruby 中的 Attribute 和 Virtual Attribute at December 23, 2013

    按照 Ruby User's Guide

    An object's instance variables are its attributes, the things that distinguish it from other objects of the same class. It is important to be able to write and read these attributes; doing so requires methods called attribute accessors.

    Attributes 是指对象的实例变量。但是我们日常使用中,习惯用 attributes 指代 attributes accessor,也就是实例变量对应的同名 setter/getter 方法,所以也才会有“Ruby 的属性其实是方法”的说法。

    Virtual attribute 不存在相对应的同名实例变量,是对其他 attribute 操作而进行封装的实例方法。

    示例,firstname,lastname 为属性,fullname 为虚拟属性:

    class Person
      attr_accessor :firstname, :lastname
    
      def fullname
        "#{firstname} #{lastname}"
      end
    
      def fullname=(fullname)
        names = fullname.split
        self.firstname = naems[0]
        self.lastname = names[1]
      end
    end
    

    上面的代码其实等价于:

    class Person
      def firstname
        @firstname
      end
    
      def firstname=(firstname)
        @firstname = firstname
      end
    
      def lastname
        @lastname
      end
    
      def lastname=(lastname)
        @lastname = lastname
      end
    
      def fullname
        "#{firstname} #{lastname}"
      end
    
      def fullname=(fullname)
        names = fullname.split
        self.firstname = naems[0]
        self.lastname = names[1]
      end
    end
    
  • RubyOnRailsTutorial 中,signout 和 current_user 的问题。 at December 22, 2013

    sign_out 之前调用过 sign_in 方法,你意思应该是在登出前先登录了一次吧?如果是这样的话,因为两次调用不是在一次请求中,登录是登录的请求,登录请求中是给 @current_user 赋了值,但该请求完毕后,所有实例变量和请求一并就销毁了。和登出请求是无关的。

  • RubyOnRailsTutorial 中,signout 和 current_user 的问题。 at December 22, 2013

    #4 楼 @cloude9101 这个就取决于你在调用 sign_out 方法之前有没有调用过 current_user 方法了

  • RubyOnRailsTutorial 中,signout 和 current_user 的问题。 at December 22, 2013

    从 current_user 方法可以看出,是通过 remember_token 来查找用户的,所以在 sign_out 中,先删除 remember_token 的话,current_user 当然找不到了,所以为 nil。

    self 只有在进行复制操作的时候,也就是 method_name = 时,为了防止其变成一个局部变量复制操作才需要加上 self,变为 self.method_name =,其他情况下是不需要加的

  • unless 不应该翻译为 “除非” at December 21, 2013

    互动百科上对“除非”的中文解释,有些意思。http://www.baike.com/wiki/%E9%99%A4%E9%9D%9E

  • 关于循环的问题 at December 20, 2013

    建议使用 partial view,可参考 http://guides.rubyonrails.org/layouts_and_rendering.html#rendering-collections

  • Ruby on Rails 4.1 发布记 at December 20, 2013

    :+1:

  • 请教一个 ruby-china 论坛代码问题 at December 18, 2013

    推荐楼主阅读 Ruby self 在不同环境的含义

  • 你可能不知道的 git rerere at December 16, 2013

    涨姿势了

  • 《Ruby on Rails 教程》Rails 3.2 版电子书免费 at December 16, 2013

    👍

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