小编Hub*_*iak的帖子

如何在 Docker Desktop 中打开选定容器的 CLI 时将默认 /bin/sh 更改为 /bin/bash?

如果我选择任何容器并单击 CLI 按钮,/bin/sh默认情况下将打开 shell。有没有办法手动重新配置Docker打开/bin/bash

docker docker-desktop

23
推荐指数
2
解决办法
1万
查看次数

NoMethodError:部署到 Heroku 时 #<Rails::Application::Configuration 未定义方法“web_console”

有什么想法如何修复它吗?网站在本地运行良好。

我的错误是:NoMethodError: undefined method 'web_console' for #<Rails::Application::Configuration

我尝试用谷歌搜索解决方案,但没有找到正确的答案。我在部署到 Heroku 时遇到此错误。

Counting objects: 134, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (131/131), done.
Writing objects: 100% (134/134), 151.11 KiB | 0 bytes/s, done.
Total 134 (delta 72), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.4
remote: -----> Installing dependencies using bundler 1.11.2
remote:        Running: bundle install …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku

6
推荐指数
3
解决办法
6552
查看次数

如何在dependecy gem中添加调试器(binding.pry)?

我想添加binding.pry以检查 kaminari gem 中的一些内容,它是 activeadmin gem 的依赖项。我也使用 kaminari 作为完全独立的 gem。

activeadmin (1.0.0.pre5)
      arbre (~> 1.0, >= 1.0.2)
      bourbon
      coffee-rails
      formtastic (~> 3.1)
      formtastic_i18n
      inherited_resources (~> 1.6)
      jquery-rails
      jquery-ui-rails
      kaminari (~> 0.16.1)
      railties (>= 3.2, < 5.1)
      ransack (~> 1.3)
      sass-rails
      sprockets (< 4.1)
Run Code Online (Sandbox Code Playgroud)

我已经在 Gemfile 中尝试过类似下面的内容:

gem 'kaminari', git: 'https://github.com/hubertjakubiak/kaminari.git', branch: 'v0.16.3'
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails pry

4
推荐指数
1
解决办法
1113
查看次数

如何在Ruby中将数组[1,2,3]映射到[1,1,2,2,3,3]?

我正在寻找最快的数组映射方式:

[1,2,3]
Run Code Online (Sandbox Code Playgroud)

[1,1,2,2,3,3]
Run Code Online (Sandbox Code Playgroud)

我最终得到了类似下面的东西.但这不是我需要的.

[1,2,3].map { |n| [n,n] } => [[1, 1], [2, 2], [3, 3]] 
Run Code Online (Sandbox Code Playgroud)

ruby

2
推荐指数
1
解决办法
173
查看次数

如何计算数字1到10的最小公倍数?

因为我是初学者Ruby开发人员.我想知道更高级的Ruby开发人员将如何解决这个问题.我在这里寻找最小的数字除以1到10之间的数字,没有任何余数.

更正式地,这被定义为两个或更多个整数的最小公倍数,在这种情况下是数字1到10.

我目前的尝试:

max_divider = 10
nums = (1..max_divider).to_a
found_count = 0
x = 0
while found_count == 0
  x += 1
  nums.each do |num|
    if x % num == 0
      found_count += 1
    end
  end

  if found_count != max_divider
    found_count = 0
  end
end

p x #=> 2520
Run Code Online (Sandbox Code Playgroud)

ruby

0
推荐指数
1
解决办法
406
查看次数

如何使这个简单的方法更短?

我的应用程序中有非常简单的方法.我想知道是否有办法让它更短.

def is_enough_words_to_play_game?
    if Word.verified.size > 5
        true
    else
        false
    end
end
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

-1
推荐指数
1
解决办法
80
查看次数

标签 统计

ruby ×3

ruby-on-rails ×3

docker ×1

docker-desktop ×1

heroku ×1

pry ×1