Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Rei
@Rei
Admin
NO. 1 / 2011-10-28

[email protected]
深圳
182 Topics / 9131 Replies
727 Followers
0 Following
11 Favorites
中下水平 Rails 程序员
Reward
GitHub Public Repos
  • writings 940

    [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

  • rich-text-editor 12

  • htmlrenderer 12

  • rails-chatgpt-demo 8

  • rails-app 7

    A Rails project template lets me start new projects quickly.

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • model 返回数组问题 at July 13, 2013

    #4 楼 @blacktulip 不要轻易露出 html_safe 和 raw

  • Partial 性能太差 at July 13, 2013

    http://ruby-china.org/topics/12008?page=1

    没贴代码之前我认为代码没写好的可能性更大,partial 我一向正常用,该用就用。

  • 基于角色的字段验证,你们是怎么做的? at July 12, 2013

    我想了想,一个 update 接口的话在发布 api 的时候有好处。做成校验的话大概是这样

    validates :xxx, length: { maximum: aaa }, :if => :role_admin?
    validates :xxx, length: { maximum: bbb }, :if => :role_editor?
    
    attr_accessor :update_role
    
    def role_admin?
      update_role == :admin
    end
    
    def role_editor?
      update_role == :editor
    end
    

    在 controller 调用的时候

    some_object.update_attributes object_params.merge(:update_role => current_user.role_for(@project))
    
  • 基于角色的字段验证,你们是怎么做的? at July 12, 2013

    #7 楼 @bydmm 是的。在前置过滤器里面检查权限。

  • 基于角色的字段验证,你们是怎么做的? at July 12, 2013

    区分不同的 action。model 加太多校验后续加功能的时候会变成负担。更分层一点可以做些中间操作对象。

  • 调用外部程序要小心 at July 12, 2013

    #7 楼 @charles 抱歉,我搞错了,数组参数需要把每个参数都分开。实际我是这么用的

    system *%W( curl -o a.png //l.ruby-china.com/photo/5982eaaa64f467d9dbda03ad4f40ea27.png )

  • 大家是怎么测试 Rails 4 的 Strong Parameters 的? at July 12, 2013

    在 controller 里面的逻辑写 controller test

  • 如何在结果集中再次查询? at July 11, 2013

    #4 楼 @loveltyoic 可以把 params 这个参数传给 url helper,例如

    search_path(params.merge :new_colun => 'value')

    得出当前查询条件再加上新条件的地址。

    或者放在 js 做,这样查询条件区域可以缓存起来。

  • 如何在结果集中再次查询? at July 11, 2013

    数据量大了上搜索引擎,搜索引擎消耗也太大就把搜索结果按查询条件缓存。

  • 如何在结果集中再次查询? at July 11, 2013

    一般做法是在当前查询条件上再加查询条件,服务端根据新的条件再查一次

  • 调用外部程序要小心 at July 11, 2013

    #1 楼 @luikore 学习了,之前不知道有 shellescape 这个方法。

    我也是用 *%W,为了避免讲解语法所以用简单的数组。

    #3 楼 @huacnlee 好东西,检出几个潜在漏洞

  • 贵圈真乱 at July 11, 2013

    男女搭配干活不累,但我觉得这个不要低俗化,拍张男女平衡朝气蓬勃的合照就好了。

  • [南京] 暴走漫画招聘 rails 程序员 (内有无节操图,慎入) at July 11, 2013

    肯定是男孩子。

  • 关于 rails 版本的选择问题 at July 11, 2013

    跟着书学,社区 wiki 更新并不及时。

  • Mongoid 里的 includes 怎么是个陷阱? at July 11, 2013

    #5 楼 @hlxwell 这两个比较不对称,要比较的是 words 用 "list_id" => id 和 words "list_id" => {"$in" => [id]} 的差别,第二个语句没有查询 words。

  • Mongoid 里的 includes 怎么是个陷阱? at July 11, 2013

    #3 楼 @hlxwell 差了多少?

  • Mongoid 能否支持虚拟字段? at July 11, 2013

    是 to_json 处理。

    试试

    get do
      User.find(...).to_json(:methods => [:name])
    end
    

    我没用过 Grape,不知道是否正确。

  • Mongoid 里的 includes 怎么是个陷阱? at July 11, 2013

    MySQL 的 in 查询也不行,即使加了索引。所以这个问题最后要用 cache 解决。

    不过我也没做过严谨测试。

  • 如何实现 hit counter 功能 at July 10, 2013

    #5 楼 @cameo 简单实现可以用 mongodb 的 addToSet,mongoid 的 add_to_set,把 ip 存进去,然后计算数组长度。数据大了再做优化。

  • 如何实现 hit counter 功能 at July 09, 2013

    #3 楼 @cameo 奥,我搞错了,counter 是这个 https://github.com/nateware/redis-objects

    unique 是指针对哪个条件?

  • slim 出错,不知道什么问题了 at July 09, 2013

    td 前面一个空格,= 前面 5 个空格,都是不合法的。

  • 如何实现 hit counter 功能 at July 09, 2013

    Ruby China 的实现逻辑在这里 https://github.com/ruby-china/ruby-china/blob/master/app/models/mongoid/counter_cache.rb

    我做的话会直接调用 mongoid 的 inc 操作。http://mongoid.org/en/mongoid/docs/persistence.html

  • Rails4.0 + mongoid3.1.4 bundle 出错 at July 08, 2013

    参考 Ruby China 的 Gemfile https://github.com/ruby-china/ruby-china/blob/master/Gemfile

    除了 Mongoid 外还有相关的 *-mongoid gem 要升级,很多都只有 git,未发稳定版。

  • 有人用 Sublime Text 3 吗 at July 08, 2013

    #27 楼 @yunzifeiyu 1 年

  • 关于 belong_to 的问题 at July 08, 2013

    user.organization.organName

  • Turbolinks 后端逻辑分析 (更新总集篇) at July 08, 2013

    #37 楼 @Victor 可以用这个插件 https://github.com/kossnocorp/jquery.turbolinks

  • 发现个不错的论坛系统 at July 07, 2013

    http://ruby-china.org/topics/8628

  • sublime text 2 自动备份文件 at July 06, 2013

    保存到 Dropbox?Dropbox 每次修改都记录版本。本地保存的问题是保存再多的版本,硬盘挂了就都没了。

  • 为什么不再来一次? at July 06, 2013

    优秀的程序员不会在生产环境测试。

  • discourse 源码中,为什么一个页面 handlebars 一份,views 一份? at July 06, 2013

    看了历史记录还真是后加的 https://github.com/discourse/discourse/commits/master/app/views/categories/index.html.erb

    Show something on categories page when js is disabled

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