Rails active_storage:安装不起作用

2023-11-22

我已将 Rails api 应用程序从 5.1 更新到 5.2。 我只使用rails api。 我正在尝试使用活动存储。我认为问题出在线路上config.api_only = true in config/application.rb.

我做了很多谷歌,但没有找到任何如何在 Rails api 中使用主动存储的东西。

这是我的Gemfile:

source 'https://rubygems.org'

ruby '2.5.1'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.2.0'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.7'
gem 'rack-cors'

# Auth
gem 'bcrypt'
gem 'jwt'

#Media file upload
gem 'activestorage'

# gem 'devise', '4.4.3'
# gem 'devise-jwt', '~> 0.5.6'
gem 'active_model_serializers', '~> 0.10.0', require: true

# backgroud jobs
gem 'sidekiq'

# fast boot
gem 'bootsnap', require: false

group :development, :test do
  gem 'rspec-rails', '~> 3.7'
  gem 'brakeman'
  gem 'rubocop'
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'foreman'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'pry'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'annotate'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

这是我的config/application.rb

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
require "active_storage"
# require "sprockets/railtie"
require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module CelebrationBackend
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Only loads a smaller set of middleware suitable for API only apps.
    # Middleware like session, flash, cookies can be added back manually.
    # Skip views, helpers and assets when generating a new resource.
    config.api_only = true

    config.active_job.queue_adapter = :sidekiq
    config.autoload_paths << Rails.root.join('lib')
  end
end

运行时rails activestorage:install进入控制台。 我收到以下错误:

铁轨已中止! 不知道如何构建任务“activestorage:install”(请参阅​​--tasks) /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:23:inblock in perform' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:20:in履行' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/railties-5.2.0/lib/rails/command.rb:48:ininvoke' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/railties-5.2.0/lib/rails/commands.rb:18:in' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:inrequire' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in阻止 require_with_bootsnap_lfi' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:inregister' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:inrequire_with_bootsnap_lfi' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:inrequire' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in阻止 require' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/activesupport-5.2.0/lib/active_support/dependency.rb:249:inload_dependency' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in要求' /home/sourabh/dev/celebration/bin/rails:9:in<top (required)>' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in加载' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/lib/spring/client/rails.rb:28:incall' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/lib/spring/client/command.rb:7:in称呼' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/lib/spring/client.rb:30:inrun' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/bin/spring:49:in' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/lib/spring/binstub.rb:31:inload' /home/sourabh/.rvm/gems/ruby-2.5.1@celeb/gems/spring-2.0.2/lib/spring/binstub.rb:31:in' /home/sourabh/dev/celebration/bin/spring:15:inrequire' /home/sourabh/dev/celebration/bin/spring:15:in' 垃圾箱/导轨:3:英寸load' bin/rails:3:in' (通过使用 --trace 运行任务来查看完整跟踪)

我不明白我做错了什么。


你的问题在这里:

require "active_storage"

您需要要求引擎:

require "active_storage/engine"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Rails active_storage:安装不起作用 的相关文章

随机推荐

  • 从 Rails 表单获取数组

    我需要设计一个表格account资源 在这种形式下 我需要收集一些 id 集作为数组params属性中的哈希值称为relationships 所以最后的params account POST 请求的哈希值应类似于 name gt somen
  • 嵌套垂直边距折叠如何工作?

    我很难理解嵌套元素中垂直边距折叠的概念 我来了一篇文章http www howtocreate co uk tutorials css margincollapsing解释它是如何工作的 但是我对其解释感到困惑 所以在它的例子中它引用了以下
  • Rails:使用多个条件连接

    我有一个简单的模型 例如 class Interest lt ActiveRecord Base has and belongs to many user profiles end class UserProfile lt ActiveRe
  • 类中 static const ODR

    我有点困惑statica 的类内初始化const成员 例如 在下面的代码中 include
  • 将 jQuery UI Accordion 放入 jQuery UI 对话框中

    通过为选项卡创建适当的标记 我已经能够将 jQuery UI 选项卡小部件放置在 jQuery UI 对话框中 但对手风琴进行同样的操作并不起作用 单击手风琴部分的锚点会导致对话框关闭 有没有一种简单的方法可以实现这一点 对我来说效果很好
  • 查找某个项目是否在 JavaScript 数组中的最佳方法? [复制]

    这个问题在这里已经有答案了 查找对象是否在数组中的最佳方法是什么 这是我所知道的最好的方法 function include arr obj for var i 0 i lt arr length i if arr i obj return
  • C# delegate 只写出最后一个方法

    我有这个代码 public void myMethod int a 10 int b 20 Func
  • 如何使用 .htaccess 重写将根 URL 重定向到子目录?

    试图得到 www example com 直接去 www example com store 我尝试了多段代码 但没有任何效果 我尝试过的 Options FollowSymlinks RewriteEngine on RewriteCon
  • Rails:在登录或注册后设计重定向到存储位置?

    我正在编写的 Rails 应用程序中使用 Devise 我想让用户在登录或注册后返回到他们所在的位置 例如 如果我有一个受以下保护的 评论 控制器 before filter authenticate user 然后我希望用户点击 立即评论
  • WPF Treeview 数据绑定混合类型的分层数据

    我的 WPF Treeview 绑定情况有点复杂 我在过去的两天里尝试用谷歌搜索它 并且this这是我想出的关闭方式 但这并不能解决问题 情况如下 我有一个看起来像这样的对象 public class Category public str
  • 窗口函数 LAG 可以引用正在计算值的列吗?

    我需要根据当前记录的其他一些列和前一条记录的 X 值 使用某些分区和顺序 计算某些列 X 的值 基本上我需要以形式实现查询 SELECT
  • 将 Spring Boot 集成到 EAR 项目中

    我有一个使用 Spring Boot 创建的现有战争项目 如何将其打包到具有 EJB 模块的 EAR 中 有没有办法将模型和 dao 包移动到 EJB 模块并用 WAR 模块注入它 您需要一个父项目 其中包括一个 war 项目 这将是您的
  • 循环遍历 LINQ 查询列(而不是行)

    是否可以循环 LINQ 查询的结果 如果可以 如何循环 像这样的东西 var results from a in dt AsEnumerable where a Field
  • 如何判断字符串是否是base64

    我有很多来自不同来源的电子邮件 它们都有附件 其中很多附件名称都是中文的 所以这些 名称由电子邮件客户端转换为 Base64 当我收到这些电子邮件时 我希望解码该名称 但还有其他名称 不是base64 如何使用以下命令区分字符串是否为 ba
  • 如何在标题标签中放置滚动文本?

    我想让标题文本可滚动 我使下面的代码滚动良好 但我输入的文本显示时没有空格 这意味着不考虑字符串中的空格
  • 如何将 URL 作为路径参数传递给 FastAPI 路由?

    我使用 FastAPI 创建了一个简单的 API 并且尝试将 URL 作为任意地址传递到 FastAPI 路由path范围 from fastapi import FastAPI app FastAPI app post path def
  • 如何保存应用了 CSS 滤镜的图像

    我想知道如何将 CSS 过滤器应用于图像 然后将图像保存到磁盘 例如 我有一个图像标签 我可以通过 CSS 应用棕褐色效果 img sepia filter sepia 20 并将该类应用于 HTML 中的图像标签 img src img
  • “for”开头的分号如何工作?

    我刚刚在 Mozilla 网站上看到了这段代码 虽然对我来说它看起来很糟糕 但我可能不熟悉它的用法 for k lt len k if k in t t k searchElement return k 循环开头的分号如何工作 完整的代码是
  • 如何在 JPA 中从 @EmbeddedId 设置反向引用

    有人知道是否可以在 JPA 内建立反向引用 EmbeddedId 例如 有一个形式的实体 Entity public class Entity1 Id GeneratedValue private String identifier pri
  • Rails active_storage:安装不起作用

    我已将 Rails api 应用程序从 5 1 更新到 5 2 我只使用rails api 我正在尝试使用活动存储 我认为问题出在线路上config api only true in config application rb 我做了很多谷