有没有人在Sinatra应用程序中为AWS S3提供资产方面有任何经验。我已经安装了宝石
asset_sync
根据https://github.com/ejholmes/asset-sync-sinatra
中的说明当我跑步时
rake assets:precompile
我在控制台中收到此错误消息
cannot load such file -- asset_sync
这是我的设置
的Gemfile
source :rubygems
gem 'sinatra'
gem 'pony'
gem 'sinatra-flash'
gem 'heroku'
gem 'activesupport', require: 'active_support'
gem 'asset_sync', git: 'git://github.com/ejholmes/asset_sync.git', branch: 'sinatra'
config.rb
module MyConfig
def config
environment = ENV["RACK_ENV"] || "development"
YAML.load_file("./config/config.yml")[environment]
end
end
config.yml
development:
aws_access_key: = 'myaccesskey'
aws_secret_key: = 'mysecretkey'
fog_directory: = 'applecatering'
Rake文件
require 'active_support/core_ext'
require 'asset_sync'
require './config/config.rb'
include MyConfig
AssetSync.configure do |con|
con.fog_provider = 'AWS'
con.fog_region = 'eu-west-1'
con.fog_directory = config['fog_directory']
con.aws_access_key_id = config['aws_access_key']
con.aws_secret_access_key = config['aws_secret_key']
con.prefix = "assets"
con.public_path = Pathname("./public")
end
namespace :assets do
desc "Precompile assets"
task :precompile do
AssetSync.sync
end
end
第一次尝试这个,任何人都可以看到我做错了什么,我错过了什么或不理解这个?
答案 0 :(得分:2)
我认为您的Rakefile
不包含Gemfile
。
尝试将其添加到Rakefile
require 'bundler/setup'
Bundler.require(:default)
尝试运行bundle exec rake assets:precompile
修改强>
此外,也许可以从require 'asset_sync'
中删除Rakefile
。 Bundler.require(:default)
应该require
Gemfile