小编oj5*_*5th的帖子

(Rails新手)rails服务器错误:无法加载此类文件 - bootsnap/setup(LoadError)

我已经将我的JS运行时安装为Node,并且我已经捆绑了update-ed和bundle install-ed,但我仍然收到此错误:

/Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/config/boot.rb:4:in `<top (required)>'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/rails:8:in `require_relative'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/rails:8:in `<top (required)>'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/spring:15:in `require'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/spring:15:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'
Run Code Online (Sandbox Code Playgroud)

这是我的Gemfile中的内容,

source 'https://rubygems.org'

gem 'rails',        '5.1.4'
gem 'puma',         '3.9.1'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem …
Run Code Online (Sandbox Code Playgroud)

ruby rubygems ruby-on-rails

6
推荐指数
1
解决办法
5782
查看次数

使用 Ruby 仅删除数组中特定的重复项

有没有办法使用 Ruby 删除数组中的特定重复项?数组示例:

["hello", "removeme", "removeme", "hello", "testing"]
Run Code Online (Sandbox Code Playgroud)

我只想删除"removeme"该数组上的重复项。期望的输出是:

["hello", "removeme", "hello", "testing"]
Run Code Online (Sandbox Code Playgroud)

有没有这样的方法来获得所需的输出?["hello", "removeme", "removeme", "hello", "testing"].uniq('removeme')

ruby arrays duplicates

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

在嵌套数组中将字符串值解析为整数

我有一个带字符串值的嵌套数组:

a = [["2000", "2004"], ["2005", "2007"]]
Run Code Online (Sandbox Code Playgroud)

我正在将值转换为整数,如下所示:

int_val = []

a.each do |a|
  int_val << a.map(&:to_i)
end

int_val #=> [[2000, 2004], [2005, 2007]]
Run Code Online (Sandbox Code Playgroud)

有没有简短的解决方案或一行代码?[["2000", "2004"], ["2005", "2007"]].map(&:to_i)不管用.

ruby

3
推荐指数
1
解决办法
154
查看次数

更改 MaterialButton 的背景色调

我使用的是最新的支撑设计:28,alpha3。

我使用“Theme.MaterialComponents.Light.NoActionBar”作为我的应用程序的主题和“ MaterialButton” ”而不是普通的“Button”。

我可以像平常一样从 XML 设置 BackgroundTind,但无法通过 java 更改它。

我试过:

deliverSwitch.setBackgroundTintList(getResources().getColorStateList(R.color.colorYellow));

deliverSwitch.setSupportBackgroundTintList(getResources().getColorStateList(R.color.colorYellow));
Run Code Online (Sandbox Code Playgroud)

但它们都不起作用...我还尝试通过将 setBackgroundTintList 保留为空来清除当前色调,但它也不起作用。

android

3
推荐指数
1
解决办法
1599
查看次数

标签 统计

ruby ×3

android ×1

arrays ×1

duplicates ×1

ruby-on-rails ×1

rubygems ×1