在Ruby中,如何添加Active_support/core_ext/time?
我找到了一些Ruby代码,可以使用:
require "active_support/core_ext/time"
require "active_support/core_ext/numeric"
Macos Monterey上的Mac上,我没有导轨或 rvm
,如果我安装 rvm
,它需要自家浏览器。要安装新的Ruby,并且可能会使事情变得更复杂,因此使用系统Ruby( Ruby 2.6.8p205
),如何安装 Accem> Accem> active_support/core_ext/time
可以使用吗?
我看了看这个问题,它无法解决问题。
我回想起我可以安装导轨:
gem install rails
但是,我必须使用 sudo
做到这一点吗? (我尝试最大程度地减少 sudo
以保持系统更安全的使用)。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
sudo
安装宝石完全是一个坏主意。最好在系统中使用一些Ruby Manager。
例如:
asdf
rvm
rbenv
chruby
您也可以使用 docker 隔离项目。
当您使用这些变体之一获得一些Ruby时,您可以使用
gemfile
或AS as terminal命令安装ActiveSupport Gem:然后您可以选择在此处需要的文件:
https://github.com/rails/rails/rails/rails/tree/main/main/main/activesupport/activesupport/lib
例如,您需要所有
时间
monkeypatches。。
因此,您需要使用:
Using
sudo
to install a gem is completely a bad idea.It's better to use some Ruby manager in your system.
For example:
asdf
RVM
rbenv
chruby
You can also use Docker to isolate the project.
When you get some Ruby using one of these variants, you can install the ActiveSupport gem with
Gemfile
or just with as terminal command:Then you can choose file(s) that will be required here:
https://github.com/rails/rails/tree/main/activesupport/lib
For example, you need all
Time
monkeypatches.There are in time.rb.
So you need to use:
要添加到 >是的,首先安装
rvm 据称将所有内容加载在 )
如果您使用的是Ruby的最新版本,具体取决于您在数字中需要的内容,而不是:
据说它加载 numeric.rb ,您可以使用:
如 Rails文档上的Ruby 。
您还可以包括以下所有内容:
如 rails on rails文档上的这个ruby 。请参阅 有关详细信息。
To add to mechnicov's answer, yes, first install something like RVM, and then
And you can use
as before (which supposedly loads everything in time.rb)
If you are using a recent version of Ruby, depending on what you need in numeric, instead of:
which supposedly loads numeric.rb, you can use:
as in the Ruby on Rails documentation.
You can also include everything by:
as in this Ruby on Rails documentation. See all.rb for details.
进行相同的操作
您可以使用
sudo gem安装Active_support
,因为您正在写入默认系统库,因此必须使用sudo。
我强烈建议使用 rbenv 或 homebrewrer“ 。
You can do the same thing using
sudo gem install active_support
You have to use sudo because you are writing to a default system library.
I would highly recommend using RBEnv or RVM, so you aren't meddling with the system Ruby constantly. It is slightly more setup, but both Homebrew and RVM are well known and supported libraries.