微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我想将 ruby​​ on rails 7.0.0.alpha 从 git 降级到 `6.1.3.2`

如何解决我想将 ruby​​ on rails 7.0.0.alpha 从 git 降级到 `6.1.3.2`

...但它仍然使用 git 版本,虽然从 Gemfile删除bundle exec 没有什么不同:

Using activestorage 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using mail 2.7.1
Using actionmailBox 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using actionmailer 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using actiontext 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
Using sprockets-rails 3.2.2
Using rails 7.0.0.alpha from https://github.com/rails/rails.git (at main@b678667)
/home/leder/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/runtime.rb:302:in `check_for_activated_spec!': You have already activated activesupport 6.1.3.2,but your Gemfile requires activesupport 7.0.0.alpha. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

更新: 我在 active_storage_main.rb 文件中降级了 rails gem,但现在我有一个不兼容的 sprockets 版本,它不在源代码中:

Installing sprockets 4.0.2 (was 3.7.2)
Using sprockets-rails 3.2.2
Using rails 6.1.3.2
/home/leder/.rbenv/versions/3.0.1/lib/ruby/site_ruby/3.0.0/bundler/runtime.rb:302:in `check_for_activated_spec!': You have already activated sprockets 3.7.2,but your Gemfile requires sprockets 4.0.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  #git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails",'~> 6.1.3','>= 6.1.3.2'
  #github: "rails/rails",branch: "main"
  gem "sqlite3"
end

require "active_record/railtie"
require "active_storage/engine"
require "tmpdir"

class TestApp < Rails::Application
  config.root = __dir__
  config.hosts << "example.org"
  config.eager_load = false
  config.session_store :cookie_store,key: "cookie_store_key"
  secrets.secret_key_base = "secret_key_base"

  config.logger = Logger.new($stdout)
  Rails.logger  = config.logger

  config.active_storage.service = :local
  config.active_storage.service_configurations = {
    local: {
      root: Dir.tmpdir,service: "disk"
    }
  }
end

ENV["DATABASE_URL"] = "sqlite3::memory:"

Rails.application.initialize!

require ActiveStorage::Engine.root.join("db/migrate/20210523072040_create_active_storage_tables.active_storage.rb").to_s

ActiveRecord::Schema.define do
  CreateActiveStorageTables.new.change

  create_table :users,force: true
end

class User < ActiveRecord::Base
  has_one_attached :profile
end

require "minitest/autorun"

class BugTest < Minitest::Test
  def test_upload_and_download
    user = User.create!(
      profile: {
        content_type: "text/plain",filename: "dummy.txt",io: ::StringIO.new("dummy"),}
    )

    assert_equal "dummy",user.profile.download
  end
end

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。