小编dmb*_*o11的帖子

Heroku:在 /app/config/storage.yml 中找不到 Active Storage 配置(运行时错误)

我的应用程序部署到 Heroku,但每次都崩溃。我不知道为什么。我已经在 Heroku 上为生产中的应用程序设置了 Carrierwave、雾和 aws,然后就好了。尝试按照相同的步骤操作,但我收到了 h10 错误代码。在 rails 控制台中,它特别指出:

/app/vendor/bundle/ruby/2.3.0/gems/activestorage-5.2.1/lib/active_storage/engine.rb:76:in `block (2 levels) in ': 找不到 Active Storage 配置 / app/config/storage.yml(运行时错误)

storage.yml 

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>


# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
amazon:
  service: S3
  access_key_id: "S3_KEY"
  secret_access_key: "S3_SECRET"
  region: "us-east-1"
  bucket: "books4reviews"
Run Code Online (Sandbox Code Playgroud)

生产.rb

  config.active_storage.service = :amazon 
Run Code Online (Sandbox Code Playgroud)

载波

CarrierWave.configure do |config|

config.fog_provider = 'fog/aws'

config.fog_credentials = {
  provider: 'AWS',
  aws_access_key_id: ENV['S3_KEY'],
  aws_secret_access_key: …
Run Code Online (Sandbox Code Playgroud)

crash ruby-on-rails heroku amazon-web-services rails-activestorage

15
推荐指数
2
解决办法
3169
查看次数

一个类被传递给`:class_name`,但我们期待一个字符串

我正在尝试创建一个名为 :books_users 的连接表,其中书籍中的一列 :claim 是一个布尔值,如果有人单击“查看此书”的链接,则书籍控制器中的声明操作会执行以下操作:

def claim
    book = Book.find(params[:id])
    book.claims << current_user unless book.claims.include?(current_user)
    redirect_to current_user
    flash[:notice] = "You have a new book to review!"
  end
Run Code Online (Sandbox Code Playgroud)

这样做的目的是让我的用户注册为评论者可以进入图书展示页面,如果他们决定评论评论者通过流派找到的作者上传的书?然后他们基本上表明他们要评论那本书,他们的评论最终将作为经过验证的购买评论显示在亚马逊上,而不是书籍显示页面上网站上的俗气文本评论(这将使注册的作者审核服务很开心)。

我的模型看起来像这样:

book.rb 

class Book < ApplicationRecord
  mount_uploader :avatar, AvatarUploader
  belongs_to :user
  has_and_belongs_to_many :genres
  has_and_belongs_to_many :claims, join_table: :books_users, association_foreign_key: :user_id

end

user.rb

class User < ApplicationRecord
mount_uploader :avatar, AvatarUploader

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
  has_many :books
  enum …
Run Code Online (Sandbox Code Playgroud)

arrays ruby-on-rails associations has-and-belongs-to-many jointable

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

我的aws密钥对在几个cmmits之后在github上

我可能在多个提交中的多个分支上有敏感的密钥信息.我很蠢.当我第一次学习aws并用雾和载波进行设置时,我甚至没有想到我的秘密密钥每次提交都会发布到github.甚至在我尝试将文件添加到gitignore之后.问题是,如何撤消发布此信息的许多提交并实现像figaro这样的gem来保持github的信息秘密?我几乎要删除我的回购...

ruby-on-rails github amazon-web-services figaro-ruby

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