![](/img/trans.png)
[英]Is it possible to pattern match on a hash value to get the hash key in Ruby 3?
這是Ruby 3中關於模式匹配的一道題。 我有一個 hash: 給定 integer(例如13 ),我想找到 hash 鍵,其 hash 值包含 integer(示例中的:y )。 當然,在 Ruby 中有一些方法可以不使用模式匹配來做到這一點。 在這里,我只對在 hash上使用 Ruby 3 的 ...
[英]Is it possible to pattern match on a hash value to get the hash key in Ruby 3?
這是Ruby 3中關於模式匹配的一道題。 我有一個 hash: 給定 integer(例如13 ),我想找到 hash 鍵,其 hash 值包含 integer(示例中的:y )。 當然,在 Ruby 中有一些方法可以不使用模式匹配來做到這一點。 在這里,我只對在 hash上使用 Ruby 3 的 ...
[英]Error on ruby upgrade to 3.1.2 from 3.0.2
我正在嘗試將我的應用程序 Ruby 版本從 3.0.2 升級到 3.1.2,但它顯示此錯誤visit_Psych_Nodes_Alias': Unknown alias: default (Psych::BadAlias) 。 有人可以指導我如何解決這個錯誤。 我試過gem rdoc --all和b ...
[英]How to use HEREDOC to pass as an argument to a method?
代碼示例:create_data_with( first: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", second: <<~TEXT Aenean vel ex bibendum, egest ...
[英]LoadError: cannot load such file -- sassc
運行rake assets:precompile以錯誤結束。 找不到為什么它仍然需要 sassc,當使用從 Sprockets 3.x 升級到 4.x 的指南遷移到 sprockets 4 時,sassc 才在項目中: 然后遵循 dartsass-rails 安裝文檔。 做過: 紅寶石-3.1.2 ...
[英]Why am I getting `ArgumentError: wrong number of arguments (given 1, expected 0)` on save?
在 test.save 升級到 ruby 3.1 后,我有這種方法給我一個錯誤ArgumentError: wrong number of arguments (given 1, expected 0) test.save! . 我努力了 和 (此方法調用如下Seeds::TestProgra ...
[英]Removing Duplicates from ActiveRecord_AssociationRelation based on foreign key
我有一個用於多對多關系的 ActiveRecord 關系,我想從關系的一側返回唯一項目的集合。 理想情況下,我想一起做這件事,但我知道這可能是不可能的。 我正在嘗試做的關鍵事情是根據外鍵刪除重復項,而不會通過調用select(:foreign_key).distinct丟失附加數據,同時保留Acti ...
[英]Ruby 3 overcommit & psych issue
我正在將 Rails 項目從 2.6.6 升級到 Ruby 3.1.2。 我最初遇到了這個問題,但通過將gem 'psych', '< 4'添加到 Gemfile 來修復它。 我應該注意到那里的答案提到降級到 Ruby 3.0.3,但這並不能解決我的問題。 添加后,該項目在 Psych 方面 ...
[英]Weird behaviour of Array index in Ruby 3.1
我不知道為什么這會在我的 ruby 中發生,但是您是否看到相同的行為? 小寫時找不到“url”。 這是保留字嗎? 編輯:似乎無法找到第一次出現的“url”字符串: ...
[英]Selenium Grid 4, How to match a particular pattern capability in ruby 3.x.x
我無法匹配 selenium 網格 4 節點的 ruby 代碼中的自定義功能。 根據此文檔: https://www.selenium.dev/documentation/grid/configuration/cli_options/#matching-node-a 我試過在 ruby 中做同樣的事 ...
[英]What's the right string to use when installing Ruby 3.1 through RVM on Mac OS Big Sur?
我正在使用 Mac OS Big Sur 和 rvm 我安裝了 Ruby 的 2.7.5 版,想安裝 3.1 版。 我試過了 當我訪問 URL https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.tar.gz時,我收到消息 我在哪里得到鑰匙? rv ...
[英]heroku[router]: at=error code=H10 desc="App crashed" method
在Ruby on Rails - Heroku 部署上,我得到了heroku[route]: at=error code=H10 desc="App crashed" method的錯誤經過一些調試日志文本后,我得到了日志文件的主要部分:2022-01-08T11:12:12.754916+00:0 ...
[英]Rails 7 Ruby 3.1 LoadError: cannot load such file -- net/smtp
我升級到 Rails 7 和 Ruby 3.1。 嘗試使用rspec運行測試時,出現以下錯誤。 我該如何解決? ...