Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
刘二狗
@coderliu
会员
第 23873 位会员 / 2015-12-07

[email protected]
厦门
2 篇帖子 / 131 条回帖
7 关注者
29 正在关注
62 收藏
GitHub Public Repos
  • iOSAnimationSample 12

    iOS animation samples from JakeLin's Swift lesson

  • Todo 2

    Swift Todo from JakeLin's lesson

  • coderliu 0

  • rubocop 0

    A Ruby static code analyzer and formatter, based on the community Ruby style guide.

  • ai-meeting-digest 0

    A full-stack Rails web application with Hotwire that allows a user to submit a raw meeting transc...

  • rubygems.org 0

    The Ruby community's gem hosting service.

  • homeland 0

    :circus_tent: Open source discussion website.

  • capistrano-sneakers 0

    Sneakers support for Capistrano

  • rms-support-letter.git... 0

    An open letter in support of Richard Matthew Stallman being reinstated by the Free Software Found...

  • graphql.github.io 0

    GraphQL Documentation at graphql.org

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • Stimulus 简介 - 谦虚的前端框架 at 2020年08月29日

    三年前线下听了分享的路过。

    感谢 Rei 的分享,我直到去年才开始用 Stimulus😂,很惭愧

  • ActiveAdmin 定制化实战 at 2020年07月14日

    感谢分享,都是一些很实用的技巧,已经接近两年没用 ActiveAdmin 了,翻了翻自己的陈年老代码,我也分享一些个人感觉有些作用的技巧吧😂

    • 指定某些 controller 下引入特定的 JS 文件。当时应该是为了只在需要用到富文本编辑器的页面去引用对应的 JS。
    # config/initializers/active_admin.rb
    module AdminPageLayoutOverride
      def build_active_admin_head
        # you can move the call to super at the end, if you wish
        # to insert things at the begining of the page
        super
    
        # this will be added at the end of <head>
        within @head do
          white_list = %w(admin/announcements admin/distributions admin/introductions admin/versions)
          if params['controller'].in?(white_list)
            text_node javascript_include_tag(params['controller'])
          end
        end
      end
    end
    ActiveAdmin::Views::Pages::Base.send :prepend, AdminPageLayoutOverride
    
    • 增加自定义的 attribute
    # config/initializers/active_admin.rb
    module ActiveAdmin
      module Views
        class RtfContent < ActiveAdmin::Component
          builder_method :rtf_content
    
          def build(content, attributes = {})
            super(attributes)
            textarea class: 'rtf-content-ckeditor', name: SecureRandom.uuid do
              content
            end
          end
        end
      end
    end
    
    • 在多个 namespace 使用 ActiveAdmin + Devise
    # config/initializers/active_admin.rb
    ActiveAdmin.setup do |config|
    #...
      config.namespace :admin do |ns|
        ns.site_title = "Admin System"
        ns.authentication_method = :authenticate_admin_user!
        ns.authorization_adapter = ActiveAdmin::PunditAdapter
        ns.pundit_default_policy = 'AdminPolicy'
        ns.current_user_method = :current_admin_user
        ns.logout_link_path = :destroy_admin_user_session_path
      end
    
      config.namespace :public do |ns|
        ns.site_title = "Public NS"
        ns.site_title_link = '/public'
        ns.authentication_method = :authenticate_teacher!
        ns.current_user_method = :current_teacher
        ns.logout_link_path = :destroy_teacher_session_path
        ns.footer = '教师工作台'
      end
    #...
    end
    
    # Devise 的处理
    class ActiveAdmin::Devise::SessionsController
      def after_sign_out_path_for(resource_or_scope)
        case resource_or_scope
        when :teacher
          new_teacher_session_path
        when :admin_user
          new_admin_user_session_path
        end
      end
    
      def after_sign_in_path_for(resource)
        case resource
        when Teacher
          public_root_path
        when AdminUser
          admin_dashboard_path
        end
      end
    end
    
  • 2.7 开始,私有方法 getter 可以显示指定 self 接收者(会和很多书上的描述打架),getter,setter 保持一致 at 2020年06月24日

    反过来想一想:如果 private 方法在 class 内部都不能调用,那什么时候允许调用?

  • 如何为当前 URL append 参数? at 2020年06月23日

    维护一个允许的参数白名单,但是新增参数的时候一不小心就会忘记掉,导致生成 URL 的时候参数丢失

  • 发现一个 bug at 2020年06月20日

    😂 我这个“新手”终于又能回帖了

  • jbuilder 使用多层 partial! 需谨慎,渲染有可能很慢 at 2020年06月08日

    之前在生产环境一个小 partial 用时是 0.1 ms,但是因为要调用 1000 次,算下里也要用 100ms,果断去掉了。楼主的 100 ms 是本地开发环境还是生产环境的数据? 如果是本地的,建议测一下 production 的情况。如果是 production 的,那多半不是 partial 的锅。

  • Shadow Table for Postgres at 2020年01月10日

    https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid

    跑个题,软删除的需求最好选择 discard,paranoia 侵入性太强了

  • Rails 项目多机部署后,job 中生成文件代码造成的困惑 at 2020年01月06日

    因为你两台服务器都是 sidekiq 的 consumer,job 可能被被分配到任意一台执行

  • 如何显示关联查询的全部内容 at 2019年09月28日

    Agency.includes(:project).where("project.score > 60")

  • 对象某个字段用了 enumerize 这个 gem,attributes 方法获取的值被改写了,有什么解决办法吗? at 2019年09月25日

    这个就是 gem 的 feature 吧

    获取原始值可以试试 user.type_id_before_type_cast

  • GitHub 宣布已经顺利升级到 Rails 6.0 at 2019年09月12日

    Running GitHub on Rails 6.0

  • [绍兴柯桥 / 杭州萧山] 有数派 诚聘 Ruby 后端、React、React Native 前端工程师 / 长期有效 ( 15K - 30K ) at 2019年08月29日

    RubyConf China 2019 最大赢家 —— 有钱派😂 👏

  • Ruby Conf China 2019 你最喜欢的主题投票 [Hot 5 已更] at 2019年08月26日

    好像没看到 @ericguo 分享的主题?


    这个: 从 Assets Pipeline 到 Webpack,Rails 6 的新前端方案们

  • RubyConf China 2019 录像 [更新完毕] at 2019年08月26日

    录制及转压幸苦了👍

  • Black candy - 基于 Rails 构建的个人音乐流媒体应用 at 2019年07月01日

    👍

  • Enumize - 扩展 ActiveRecord::Enum 增加实用方法 at 2019年06月24日

    很实用,以前都是手动调用 i18n 👍

  • [上海][8-24,25] RubyConf China 2019 售票开始 at 2019年06月20日

    性感姜军,在线卖票,不买即亏

  • [上海][8-24,25] RubyConf China X 讲师和主题介绍 at 2019年06月20日

    期待👏

  • Rails API 项目的后台 怎样写会比较好呢 at 2019年05月12日

    https://medium.com/alturasoluciones/how-to-set-up-rails-api-app-to-use-activeadmin-79b418df8aad

    https://blog.heroku.com/a-rock-solid-modern-web-stack

    放一个项目里没什么问题,就算你原来是个 api mode 的项目,也可以往里加 activeadmin

  • [北京] [2019年3月9日] Ruby Saturday「结束,包含 Keynotes」 at 2019年03月12日

    keynote 链接都是错的

  • 关于腾讯 API 拼 URL 的服务 at 2018年12月15日
    RestClient::Request.execute(method: :get, url: 'http://example.com/resource',
                                timeout: 10, headers: {params: {foo: 'bar'}})
    # ➔ GET http://example.com/resource?foo=bar
    

    当年也是因为要用腾讯的 API 才知道 RestClient 还可以这么用的

  • It's never too late to learn Postgres at 2018年11月24日

    炮神可以分享一下你的 PG 学习路线吗?

  • [深圳] 中原地产 诚邀 Ruby 软件工程师~ at 2018年11月22日

    不如从门店拉几个中介从 0 入门吧

  • Ruby China 的最后回覆里有个 bug at 2018年11月19日

    应该是机器人被屏蔽了

  • [远程] FeedMob 诚招 Ruby Developer 和 DBA (已招满) at 2018年11月15日

    简历已发邮箱,期待回复😬

  • 如何给 Rails 做 health check at 2018年11月10日

    /health 会 timeout,说明此时该服务器的负载确实已经太高了。要么你的 timeout 太小了,要么就是触发创建新 container 条件不够“敏感”

  • Rails job 默认的 Active Job 如何不并发调同一方法 顺序执行方法 at 2018年11月09日

    生产环境使用 Sidekiq 的话可以创建一个长度为 1 的队列专门用来跑这类任务,这样不会影响到并行的其它任务。有这种需求直接在开发环境就用 Sidekiq 吧

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