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

[email protected]
深圳
188 Topics / 9152 Replies
730 Followers
0 Following
11 Favorites
中下水平 Rails 程序员
Reward
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

  • geeknote 15

  • rich-text-editor 12

  • htmlrenderer 12

  • rails-chatgpt-demo 8

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Turbolinks 遇上 多说 at August 26, 2015

    这段代码是在 head 插入 script 引入外部脚本然后立即执行,试试去掉这段代码,在 </body> 前插入

    <script src="//static.duoshuo.com/embed.js" async></script>
    
  • 支付宝 API 向导 (Ruby 版),以及开源一个支付宝 gem at August 25, 2015

    #56 楼 @osbron 顶楼的博客关了,新地址 http://chloerei.com/2013/08/01/alipay-payment-in-ruby/

  • 怎样只用 friendly_id,禁用主键 id at August 24, 2015

    #12 楼 @peter 情况越复杂,定制程度越高,改 gem 越麻烦。不过你用得爽我也不反对。

  • Ruby 方法的执行结果默认为 “最后一条语句的结果”*3 (重要的事情要说三遍!) at August 24, 2015

    标题很无聊。

  • gem install pg 遇到的问题 at August 24, 2015

    #8 楼 @drine 是怎么把 pg 装到那个位置的?

  • 怎样只用 friendly_id,禁用主键 id at August 24, 2015

    如果你说的是生成 url。

    def to_param
      "#{first_name}-#{last_name}"
    end
    
  • 怎样只用 friendly_id,禁用主键 id at August 24, 2015

    #8 楼 @peter 定义方法为什么要改 view 和 route?MVC 不就是为了解藕么。

  • 怎样只用 friendly_id,禁用主键 id at August 24, 2015

    定义一个方法不就好了。

    def find_by_friendly_id(id)
      first_name, last_name = id.split('-')
      find_by! first_name: first_name, last_name: last_name
    end
    
  • Rails 中如何实现登录次数尝试过多锁定十分钟 at August 24, 2015

    #15 楼 @jasonpu http://guides.ruby-china.org/caching_with_rails.html#activesupport::cache::memcachestore

  • Rails 中如何实现登录次数尝试过多锁定十分钟 at August 24, 2015

    #7 楼 @nowherekai 用 memcached 或 redis。

  • Rails 中如何实现登录次数尝试过多锁定十分钟 at August 24, 2015
    def show
      if Rails.cache.increment("login/ip/#{request.ip}",  0, expires_in: 10.minutes).to_i > 3
        render :ip_limit
      else
        # login form
      end
    end
    
    def create
      if Rails.cache.increment("login/ip/#{request.ip}", 1, expires_in: 10.minutes) > 3
        render :ip_limit
      else
        if success
          # login
          Rails.cache.delete("login/ip/#{request.ip}")
        else
          # render :show
        end
      end
    end
    

    补充:

    1. 基于 dalli(memcached)
    2. 读 increament 的值要用 increament 0 https://github.com/mperham/dalli/issues/463
  • Rails 中如何实现登录次数尝试过多锁定十分钟 at August 24, 2015

    #1 楼 @msg7086

    Rails 的精髓就是:能多用第三方组件的,绝对不要自己写。

    不赞成,看情况。

  • 如何提高 rails server 启动速度? at August 23, 2015

    https://docs.vagrantup.com/v2/synced-folders/nfs.html

  • 大家好,问一个 Ruby 的基础问题。 at August 22, 2015

    发代码不要用截图。

  • 请教更简洁的写法 at August 21, 2015
    class User
      has_many :memberships
      has_many :circles, through: :memberships do
        # Association Extensions
        def status(status)
          where(memberships: { status: status })
        end
      end
    end
    
    class Membership
      belongs_to :user
      belongs_to :circles
    end
    
    class Circle
      has_many :memberships
      has_many :users, through: :memberships
    end
    
    # Association
    User.first.circles.where(memberships: { status: status})
    # Association Extensions
    User.first.circles.status(status)
    
  • 请教更简洁的写法 at August 21, 2015
    Circle.joins(:memberships).where(memberships: { status: status, user_id: id })
    
  • [广州] (外资) 诺特软件 诚招 Ruby 技术顾问 1 人,Ruby 开发工程师 3 人 at August 21, 2015

    #2 楼 @gztheknot pass

  • [广州] (外资) 诺特软件 诚招 Ruby 技术顾问 1 人,Ruby 开发工程师 3 人 at August 21, 2015

    https://ruby-china.org/topics/25579

    请不要包含如“公司美女如云”等不符合技术社区价值观的内容,如果发布类似“急招 Ruby 程序员,QQ 号 xxxxx”这样的马路小广告式的招聘贴,见一个,删一个,决不姑息!

  • 使用 4.2 的 active_job 和 Sidekiq,但是不工作 at August 20, 2015

    启动了 worker 没?

  • Ruby 2.2.2 使用中的问题 at August 18, 2015

    有啊 http://ruby-doc.org/stdlib-2.2.2/libdoc/securerandom/rdoc/SecureRandom.html

  • 求助 ,上传照片出现 RequestURITooLarge 错误 at August 17, 2015

    #4 楼 @liguangsong 可能默认加载的 jquery-ujs 被去掉了,看看 application.js

    https://github.com/rails/jquery-ujs

  • 求助 ,上传照片出现 RequestURITooLarge 错误 at August 17, 2015

    用 POST

  • 前方有坑,请注意。。。 蛋疼的 first_or_create at August 16, 2015

    #16 楼 @zhangjinzhu 我第一时间看不懂,以为 SELECT 语句是对应最后一行代码。

    调试了一下,似乎 find_or_create 语法没有这个问题。试试:

    order.items.find_or_create_by(product_id: 888)
    
  • 前方有坑,请注意。。。 蛋疼的 first_or_create at August 16, 2015

    看起来是同一个问题 https://github.com/rails/rails/issues/9894

  • 前方有坑,请注意。。。 蛋疼的 first_or_create at August 16, 2015

    这就是不好好说话,浪费双方时间的例子。

    顶楼意思是:

    item = order.items.where(product_id: 888).first_or_create
    
    # 在 item 的回调中
    order.items
    # => SELECT `order_items`.* FROM `order_items` WHERE `order_items`.`product_id` = 888 AND `order_items`.`order_id` = 99
    # 多了一个 product_id
    
  • 前方有坑,请注意。。。 蛋疼的 first_or_create at August 16, 2015

    问题在哪?

  • 求助:rails 使用 link_to 跳转到目的页面后 jquery 的 ready 函数不起作用,必须刷新页面才行 at August 15, 2015

    http://guides.ruby-china.org/working_with_javascript_in_rails.html#turbolinks

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