Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
qinfanpeng
@qinfanpeng
高级会员
第 3790 位会员 / 2012-09-27

金数据(https://jinshuju.net/)
成都
55 篇帖子 / 572 条回帖
38 关注者
32 正在关注
34 收藏
GitHub Public Repos
  • echart_subway_demo 0

  • subway_demo 0

  • spike-mysql 0

    spike insert 1000w data to mysql

  • merchin_learning_in_ac... 0

    merchin_learning_in_action paractice

  • qinfanpeng.github.io 0

  • gold-miner 0

    掘金翻译计划,翻译掘金上优质的英文文章

  • tooltipster 0

    A jQuery tooltip plugin

  • bootstrapx-clickover 0

    Bootstrap Extension for Click managed popovers

  • english_usage 0

  • decorator_pattern_shape 0

    Demo for decorator pattern

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 理解 Ruby 中的 include 和 prepend at 2016年01月13日

    代码高亮一下会不会好点

  • Ruby 常量查找 (译) at 2016年01月12日

    感觉不用删吧,还是有不同地方的,留着吧。貌似有人评论过的帖子就不能被删除了。

  • 判断 Rails partial 中变量是否定义的正确姿势 at 2016年01月12日

    If you need to check for the presence of a certain local variable in a partial, you need to do it by checking the local_assigns hash that is part of every template. Using defined? variable won’t work due to limitations of the rendering system.

    -iflocal_assigns.has_key?:special
      = special
    
  • Ruby 常量查找 (译) at 2016年01月12日

    辛苦辛苦,不过有篇相似度很高的文章,https://ruby-china.org/topics/26890。

  • 为何使用了 Turbolinks 以后,jquery_ujs 里的 Event 被重复 bind 了多次? at 2016年01月11日

    #11 楼 @adamshen 😓惭愧

  • 为何使用了 Turbolinks 以后,jquery_ujs 里的 Event 被重复 bind 了多次? at 2016年01月11日

    #8 楼 @rei 厉害,他这个问题我看了半天没眉目,只是感觉把 nav 标签放到 head 里很奇怪,没想到会是这样。还是你们这些前辈有经验。:plus1:

  • GitHub 秘籍 at 2016年01月11日

    :plus1: 不错

  • 为何使用了 Turbolinks 以后,jquery_ujs 里的 Event 被重复 bind 了多次? at 2016年01月10日

    看看你的代码里是否这样的代码 $(document).on "page:load", ->,其中的page:load每次因 Turbolinks引起的切换页面都会执行里面的逻辑。我猜想你需要的是这样的代码 $(document).on "ready", ->,这个只在第一次加载后 dom ready 才执行,后面因 Turbolinks引起的切换页面都不会再执行了。

  • 如何理解 Module 类里面的 module methods at 2016年01月10日

    #16 楼 @torubylist 你要找的话也该是看 Ruby 的 API,而非 Rails 的。

  • 如何理解 Module 类里面的 module methods at 2016年01月10日

    #18 楼 @torubylist 我用的是 Dash

  • 使用 Ruby 的单元测试,如何使异常抛出 at 2016年01月10日

    #3 楼 @davidwei 有插件推荐吗?用 puts 是我一般先打印一行 "--------------------",然后接着打印自己要看的东西,另外用 asome print 打印的是彩色的,很好辨识的。

  • 使用 Ruby 的单元测试,如何使异常抛出 at 2016年01月10日

    #1 楼 @xiaoronglv :plus1: @hgyxbll,要是你懒得引入 pry 的话,最原始的办法就是在怀疑有问题的地方 puts,另外如果用 Rubymine 这类的 IDE 的话,直接 debug 方式运行测试吧。

  • 理解一段计算文本行数的代码 at 2016年01月10日

    @runup 感觉你把问题弄复杂了,本来 ltotal 就是用于递增接收总行数的,你又引入一个变量 l ,他们干的事情没法不同。

  • 如何理解 Module 类里面的 module methods at 2016年01月09日

    #7 楼 @runup 感觉还没到 C 语言那一块,更多的是其实现细节这些吧

  • 关于在 Rails Model 中使用 Enum (枚举) 的若干总结 at 2016年01月09日

    #8 楼 @adamshen 默认有 scope,你自己再弄一个,基于啥考虑?

  • 关于在 Rails Model 中使用 Enum (枚举) 的若干总结 at 2016年01月09日

    #6 楼 @blueplanet :plus1:

  • 你想要的 Docker 容器集群技术基本都在这里了。。。 at 2016年01月08日

    老熟人了,顶一个。

  • will_paginate 分页过多 (大概 10000 页),点击最后几页的时候,速度明显变慢 at 2016年01月08日

    #2 楼 @bright +1

  • 关于在 Rails Model 中使用 Enum (枚举) 的若干总结 at 2016年01月08日

    :plus1:

  • 如何在用户注册表单获取 text_field value 并通过参数传到 controller 中 at 2016年01月08日

    #17 楼 @springwq @helperhaps 的方案也可以,不过有个问题是 form 不能嵌套,也就是说你的手机号字段要么放到最前面,要么放在最后面。

  • 不能直接用 1 来判断值为 true 的记录,但在 where 的查询里却可以用 1 查询到值为 true 的记录 at 2016年01月08日

    #4 楼 赞同 @huacnlee 的说法。参考:

    The Active Record connection adapters, classes that implement behavior specific to databases, fetch results as strings and Rails takes care of converting them to other datatypes if necessary, based on the type of the database column. For instance, integer types are cast to instances of Ruby’s Fixnum class, and so on. Even if you’re working with a new instance of an Active Record object, and have passed in constructor values as strings, they will be typecast to their proper type when you try to access those values as attributes. Sometimes you want to be able to read (or manipulate) the raw attribute data without having the column determined typecast run its course first, and that can be done by using the attribute_before_type_cast accessors that are automatically created in your model.

  • 如何在用户注册表单获取 text_field value 并通过参数传到 controller 中 at 2016年01月08日

    #7 楼 @springwq 你这里肯定就不能这样写了,把<%= link_to send_sms_users_path, method: :get, id:"send_sms",remote: true do %> <span id="send_sms">获取验证码</span><% end %> 换成按钮之类的,在 js 里区监听点击事件,然后触发 Ajax 请求。 另外send_sms.js.erb不是你这样用的,它一般用于返回一段简单的 script(太复杂的别这样搞,你会后悔的)给浏览器,浏览器会自动执行。建议还是系统地看书学习一下。

  • Rails association 中的 foreign keys at 2016年01月07日

    #18 楼 @redemption 补充一点:

    As we work toward the end of this book’s coverage of Active Record, you might have noticed that we haven’t really touched on a subject of particular importance to many programmers: foreign-key constraints in the database. That’s mainly because use of foreign-key constraints simply isn’t the Rails way to tackle the problem of relational integrity. To put it mildly, that opinion is controversial and some developers have written off Rails (and its authors) for expressing it. There really isn’t anything stopping you from adding foreign-key constraints to your database tables, although you’d do well to wait until after the bulk of development is done. The exception, of course, is those polymorphic associations, which are probably the most extreme manifestation of the Rails opinion against foreign-key constraints. Unless you’re armed for battle, you might not want to broach that particular subject with your DBA.

    ---- 摘自《The Rails 4 Way》

  • 踏入程序猿圈子后,作息正常的还有多少? at 2016年01月07日

    #21 楼 @xiaoronglv 咋个感觉该是自己早睡早起一次,给自己 100 的奖励喃。

  • 如何在用户注册表单获取 text_field value 并通过参数传到 controller 中 at 2016年01月07日

    暂不清楚你send_sms.js.erb这里是做啥用的,不过参考 jQuery 代码如下:

    $.post 'send_sms_users_path',
           data: { phone_number: $("#phone_number").val() }
    
  • 如何理解 Module 类里面的 module methods at 2016年01月07日

    可以看出 module_function 和 private 都是 Module 类的实例方法。但是:

    Module.methods.grep /^priva/
    => [:private_instance_methods,
     :private_constant,
     :private_method_defined?,
     :private_class_method,
     :private_methods]
    
    Module.methods.grep /^mod/
    => [:module_exec, :module_eval]
    

    其中原因暂时不知,若知晓,勿忘告知。

  • 如何理解 Module 类里面的 module methods at 2016年01月07日

    不得不说你把本来就不好懂的问题,描述得更不好懂了

  • 如何在用户注册表单获取 text_field value 并通过参数传到 controller 中 at 2016年01月07日

    点获取验证码,用 js 发 Ajax 请求去弄?

  • 踏入程序猿圈子后,作息正常的还有多少? at 2016年01月07日

    #5 楼 @smallx +1,虽感觉早起有点反人性,但晚睡却是我们自己不容易管住自己的表现。

  • 踏入程序猿圈子后,作息正常的还有多少? at 2016年01月07日

    #3 楼 :plus1: @chareice 在空气质量低于 100 的时候坚持跑步,阻止自己晚睡。

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