访问被拒绝,你可能没有权限或未登录。
  • 直接加 on_delete: :cascade 的选项实际是在 DB 层做的级联删除,不是由 rails 在模型层做的删除,rails 日志应该不会体现 DB 层删除子记录。8 楼老哥的日志是能看到子记录和父记录放在同一个事务中的删除,所以你俩的代码其实不一样。(不排除版本差异问题)

    不过确实能实现效果,而且这种形式是 gitlab 更倡导的级联删除方式。

  • 通过对这些 Gem 的功能片段的阅读,可以让源码新手能从易到难,循序渐进的去培养阅读源码的能力。

    这是个很理想的想法。多年前的我也有些这样的想法,想着先读完一个难度为 1 的源码,再去读难度为 2 的源码,逐渐继续,那么就能读下来难度为 100 的源码。但现实是复杂的,源码并不会标注自己是难度 1 还是难度 2,"难易"的评判是一个小马过河式的问题。

    我跟 5 楼和 7 的看法一样,真要读 gem 源码时,一般是在使用 gem 时产生了些疑惑,或者需要魔改 gem。把“阅读源码”本身当作阅读源码的目的,我自己的结果是,容易失去重心,最终只学到些没见过的语法糖和 API。

    如果楼主非要读 gem 源码,在掌握调试技能和熟悉 gem 公开 api 前提下,拉取 gem 的最初版本代码,配合他的单元测试,顺着测试单步调试,再难的 gem 都能看下来。当然,如果 gem 的单测写得不好,很可能说明没啥阅读价值。。。。

  • 回流招聘 “血泪史” at 2022年03月22日

    老哥你们要是把大小周去掉,估计人就会多些。看起来是每两周只多上一天的班,但一年算下来得多上一个月的班。这得多少个年假才抵得过来啊

  • 有过。个把月都没有人说话

  • 顺便提一句,在定义类时,rails 不提倡使用“限定常量”的形式,而是使用“相对常量”的形式,否则对于 classic 的 autoloader,有时会产生诡异的类加载错误。因此 class Api::V1::Com::OptionsController 最好能写成

    module Api::V1::Com
      class OptionsContoller < Api::V1::Com::BaseController
      end
    end
    

    对于 Zeitwerk 的 autoloader,这两种写法没有区别

  • 那就需要更多的信息了,坑可能在其他地方。rails 的常量自动加载机制已经变过几次了。随手试了下,这点代码信息在 rails 6 上没有复现问题。

  • 错误信息就是答案

    Unable to autoload constant Api::V1::Com::OptionsController, expected /mnt/workspaces/rails_projects/reviewservice/app/controllers/api/v1/com/options_controller.rb to define it

    翻译:不能自动加载常量 Api::V1::Com::OptionsController,期望在 /mnt/workspaces/rails_projects/reviewservice/app/controllers/api/v1/com/options_controller.rb 中去定义这个常量。

    类名与文件层次不对应

  • rails_param 这个 gem 倒是内置了你要的效果,在 action 中使用param! :tag_ids, Array 就能把逗号分隔的参数转为数组。不过单纯为了这个功能而引入一个 gem 有点划不来,可以考虑自己手动封装个类似的方法。

  • 写成这样也 ok。但为什么不直接传数组勒

  • Tesla backend is in Rails at 2022年03月10日

    no wonder some parts are so slow...

  • Hello Ruby China from Russia at 2022年03月05日

    @woto From what I see, there are few foreign developers in China because of the salary and language. And ruby is not very popular in China. As a result, there is only one or two recruitment information per month in RubyChina; you can see it here.

    The good news is that Chinese companies and the government don't care about your nationality. They will NOT ban you because of Russian citizenship.

    It seems you are a very seasoned developer, that's great; I think many employers would like to contact you if you can speak some Chinese. I know some companies spend years finding a good rails developer.

    A little more suggestion

    1. This forum supports markdown. Maybe you can use it to make your post more formal. And please put the important information about your skills and experiments in the post itself, not only in the replies.
    2. You can try to append "俄国资深全栈工程师寻远程工作" to your title, these Chinese characters mean "Russian seasoned full-stack developer looking for a remote job". This would make your post look more meaningful on the index page in my opinion.
    3. Usually, there are far more people in RubyChina on weekdays than on weekends. So you may wait until Monday or later to get more replies.
    4. You can try to look for some information in Japan's forum. They are very lacking developers, as I know.

    I hope here will help you.

  • Hello Ruby China from Russia at 2022年03月05日

    This was the first time I knew that a European developer was looking for a job in China. It seems the world is changing 😀 .

    Although I can't help too much, I suggest you leave more information to help recruiters in RubyChina get to know you better, such as your working experience, skill stack, your Github, and so on.

  • 我读 unless 的逻辑的时候脑子里会自动翻译成 if !xxx

  • 醪糟

    边喝酒边敲代码,细想下还有点诗意啊

  • 要用文件系统来存附件的话,docker 容器应该要配个数据卷吧。

  • 点赞。当初在 BOSS 上聊过,感觉老哥招人还是挺有诚意。不过因为 BOSS 的消息丢失没有看到面试消息(顺便吐槽下 BOSS 有时候真坑),于是去了另一家。没想到现在还在招人

  • rvm 被墙了怎么办 at 2022年02月10日

    试试 asdf。我现在逐步用 asdf 取代 rvm,主要本地环境中的 python,nodejs,ruby 都需要个版本管理工具,恰好 asdf 都支持,正好统一了

  • Ruby 开发人员流失严重 at 2022年01月14日

    排名改了之后俺也上榜了。激动😁

  • 我当时也遇到了这个问题。重新设置 config.file_watcher = ActiveSupport::FileUpdateChecker 后,改了 ruby 代码也能正常同步,但是 js 文件一直不能自动编译。迁移到 wsl 内部文件系统就又快又正常了

  • 谢了老哥,果然有这样的 gem

  • 好总结。以前试过这种方案,觉得稍微有点 hack 就没这么整😀

    捉个虫:

    tag_ids = ActsAsTaggableOn::Tag.where(name: 'Rails').pluck(:id)
    

    应该是

    tag_ids = ActsAsTaggableOn::Tag.where(name: tag_name).pluck(:id)
    

    顺便问一下楼主:ActsAsTaggableOn::Tag 是在模型下建的命名空间么,还是用的 gem 的要求

  • 顺手在 rails 6.1.1 上试了下,完全没复现。一切正常

  • null at 2021年11月02日

    老哥,我感觉你链接都贴错了

  • module Pipline
      def self.included(base)
        class << base
          attr_accessor :seg_column_name
        end
      end
    end
    
    class A
      include Pipline
      self.seg_column_name ='a'
    end
    
  • 不懂就问:数仓具体是干啥的

  • 楼上老哥这么一提,我倒是想起那个赌博老哥了,连载好多年,中途也是培训上岸,最后好像忍不住又亏回去了,大风大浪的故事。

    成年人全都要,先搞 rails 后搞 go

  • 没有必要了吧。除非你打算把 docker 当虚拟机用。。。我见过在 docker 里先装 linux,再装 rbenv,再装 ruby 的情况(当然还有一大堆依赖),整个镜像大概 4G。完全不理解这样搞的好处。

  • 关注了一个女 rubist at 2021年08月13日

    没看到 ruby 代码勒?