Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
yang
@heroyct
Member
NO. 33357 / 2017-10-26

18 Topics / 140 Replies
8 Followers
0 Following
2 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 大家一般线上环境的 migration 在什么时候执行? at April 30, 2025

    deploy 的时候启动一个单独的 ecs task 来 migrate(CI 里)

  • 编程语言学习与人文语言学习是否有共同之处 at January 10, 2024

    和编程做个好玩的东西一样,找人讲英语也许是最快的。

  • Turbo 8 beta 版放出来了 at November 28, 2023

    终于不需要用 turbo_stream 逐个指定更新的位置了?
    感觉不错。

  • 为什么感觉国内很多 app 界面做得很生硬? at April 28, 2023

    我倒觉的 wechat 比 line 好用多了,
    line 的主页杂乱不堪,啥都有,对于只用来聊天的我来说,实在欣赏不来。

    淘宝,京东的网购用户体验比日本乐天,亚马逊好太多,个人感觉不是一个档次。
    槽点无数,就不一一列举了,用过的都知道。

  • CSS 设计之 ITCSS at September 24, 2022

    不需要,直接写 CSS 也行

  • stimulus.js 初体验 at September 10, 2022

    确实比较麻烦,我是把 react 的 state bind 到 DOM 的 data 属性里面,再从 DOM 的属性读取。
    交互度高的页面目前是整个页面全部写成 react。

  • stimulus.js 初体验 at August 18, 2022

    新项目试了下 turbo + stimulus,感觉还不错。复杂的组件在 Controller 里面 render react。

  • simple_form 如何根据不同的 url 使用不同的设置 at June 29, 2022

    看了下 ISSUE 好像不打算实现类似的 feature,在项目里面扩展了一下。

    class Admin::BaseController < ApplicationController
      around_action :use_simpleform_admin
      def use_simpleform_admin
        SimpleForm.use_namespace(:admin) do
          yield
        end
      end
    

    Config

    SimpleForm.use_namespace(:admin) do
      SimpleForm.setup do |config|
        # some config for admin only
      end
    end
    

    extend

    # frozen_string_literal: true
    require 'simple_form'
    require 'simple_form/form_builder'
    module SimpleForm
      module Namespace
        extend ActiveSupport::Concern
    
        DEFAULT_VALUES = SimpleForm.class_variables.index_with {|k| SimpleForm.class_variable_get(k) }
    
        def current_wrappers
          current_configuration[:@@wrappers]
        end
    
        def use_namespace(name = :default)
          old_namespace = current_namespace
          switch_namespace(name)
          yield
        ensure
          switch_namespace(old_namespace)
        end
    
        def switch_namespace(namespace)
          Thread.current[:simple_form_namespace] = namespace
        end
    
        def current_namespace
          Thread.current[:simple_form_namespace] ||= :default
        end
    
        def builder_discovery_cache
          current_configuration[:@@discovery_cache] ||= {}
        end
    
        def custom_wrapper_mappings
          current_configuration[:@@custom_wrapper_mappings] ||= {}
        end
      end
    
      extend Namespace
      @configurations = {}
      def self.current_configuration
        @configurations[current_namespace] ||= Namespace::DEFAULT_VALUES.deep_dup
      end
    
      SimpleForm.class_variables.each do |k|
        method = k.to_s.tr("@@", '')
        setter_method = "#{method}="
        if SimpleForm.respond_to?(setter_method)
          define_singleton_method(setter_method) do |v|
            current_configuration[k] = v
          end
        end
        next unless SimpleForm.respond_to?(method)
        define_singleton_method(method) do
          current_configuration[k]
        end
      end
    
      def self.wrapper(name)
        current_wrappers[name.to_s] or raise WrapperNotFound, "Couldn't find wrapper with name #{name}"
      end
    
      # Define a new wrapper using SimpleForm::Wrappers::Builder
      # and store it in the given name.
      def self.wrappers(*args, &block)
        if block_given?
          options                 = args.extract_options!
          name                    = args.first || :default
          current_wrappers[name.to_s] = build(options, &block)
        else
          current_wrappers
        end
      end
    
      SimpleForm::FormBuilder.define_singleton_method(:discovery_cache) do
        ::SimpleForm.builder_discovery_cache
      end
    end
    
  • React 中 input 元素的 onChange 事件怎么没有执行? at May 26, 2022

    找了一大圈,发现在 react 中,通过代码的方法修改 input 的 value 不会触发 input 的 onChange 事件,要自己分发事件才行??只有手动输入才会触发。

    是的,和你说的一样。stackoverflow 有类似问题,可以参考下。

    • https://stackoverflow.com/questions/58985059/why-changing-value-in-state-doesnt-trigger-onchange-of-input-element-in-react
    • https://hustle.bizongo.in/simulate-react-on-change-on-controlled-components-baa336920e04

    可以使用 useEffect

    useEffect(() => {
      onChange(time);
    }, [time]);
    
  • React 中 input 元素的 onChange 事件怎么没有执行? at May 26, 2022

    绑定 value 不会触发 input 的 onChange 事件。

    直接在这里抛出。

    const setFormatTime = (hour, minute) => {
      const inputTime = padLeadingZeros(hour, 2) + ":" + padLeadingZeros(minute, 2);
      setTime(inputTime);
      onChange(inputTime);
    }
    
    // 父元素
    const handleTimeInputChange = (time) => {
      console.log(`current_time: ${time}`);
    };
    
  • 多文件上传 at April 26, 2022

    可以试试这个。

    https://www.dropzone.dev/js/

  • 请问怎么让 CircleCI 跑子目录的测试代码? at March 11, 2022

    直接跑脚本应该可以。可以重新开一个 jobs,然后并行测试。

    类似这样

    jobs:
      front_test:
        steps:
          - run:
              name: front test
              command: #{ your test command }
    
  • 关于远程 at February 16, 2022

    gitlab 的远程感觉感觉挺牛的,也许能借鉴一些。

    https://about.gitlab.com/company/culture/all-remote/guide/

  • 有没有检查 html 标签嵌套是否规范的 npm at January 17, 2022

    https://github.com/dutchenkoOleg/node-w3c-validator#readme

  • 求一个 DDD 的 Rails Gem at December 03, 2021

    https://blog.slava.dev/domain-driven-design-for-ruby-on-rails-d3dd4a606677 https://github.com/Creditas/ddd-rails-sample

  • null at December 01, 2021

    虽然没用过,cloud9 也许不错。

    https://aws.amazon.com/cn/cloud9/getting-started/

  • 搞了一个踩坑社区,试运营中........ at November 18, 2021

    踩坑才是提升技术的最好办法。

  • Ruby China 社区里全栈工程师的具体定义是什么 at October 11, 2021

    https://github.com/kamranahmedse/developer-roadmap

  • ruby 内存持续增加,无法垃圾回收 at August 12, 2021

    puma 的话试试 jemalloc

  • Rails on Cloud(Rails 微服务实践理论) at May 24, 2021

    微服务里面的服务 (service) 用什么语言都行吧,这不正是微服务的一个优点吗?用 rails 当然也可以

    可以参看图灵出版的微服务设计

    感觉文章写的是微服务之间的管理,确实不是 rails 干的事情。

  • 有人用 TruffleRuby 和 Rails 在生产环境吗? at May 14, 2021

    以前下来玩了一下,发现不能在 rails 下运行,就没关注了 不知道最近兼容性咋样

  • Rails 因為 mimemagic 炸了 at March 25, 2021

    https://github.com/rails/rails/issues/41750#issuecomment-805803294 版本 0.3.6、0.4.0 好像没问题

  • 现在技术基本上没有发言权了,资本操控一切 at July 13, 2020

    日本招 rails 的挺多,虽然还是没 JAVA 多!

    https://www.green-japan.com/search_key/01?key=2vkn2gx21xjyx34dfj15&keyword=Rails

  • 83 行 Ruby 的蓝调即兴生成器 at April 23, 2020

    看来是时候学的音乐了😀

  • DHH 最新博客——“雄伟巨石”可以成为“城堡” at April 16, 2020

    我不由自主的笑了😆

  • 可能会影响程序员职业生涯的七本书 at March 26, 2020

    http://lucida.me/blog/developer-reading-list/

    以前看到的书单,到现在为止都没看完😅

  • 想请问一下关于 travci、rails、vue 的配置问题 at March 23, 2020

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

    feature 测试坑有点多,这篇帖子希望能帮到你。

    没必要用 feature 测试就用其他测试吧。

  • 使用 GitHub Actions 自动删除 merged branch at March 23, 2020

    @franklinyu 多谢,已经用上了。

  • deploy 时,yarn 为什么那么慢? at March 16, 2020

    一般需要缓存,每次都去下载肯定不快。 不知道你用什么 deploy 的,用 circleci 之类的缓存很简单。

  • 最近在用 VS Code 玩儿 Flutter,在跑 Ruby on Rails 的时候总觉的非常不顺手 at March 11, 2020

    默认的设置不太够,稍微设置一下,用起来就好多了。

    • Beginners guide for a Ruby-on-Rails ready Visual Studio Code
    • The three extensions you need for Rails development in VS Code
    • VSCode の拡張機能で Rails と仲良くなる
  • 1
  • 2
  • 3
  • 4
  • 5
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English