Ruby on rails Heroku部署:URI::InvalidURIError:错误的URI(不是URI?)://用户:pass@127.0.0.1/数据库名
我有一个带有Vue前端和rails后端的项目。它只是后端的一个非常简单的API,没有数据库或任何东西。它在本地运行良好,但现在我想在Heroku上部署它 然而,当我运行它时,我得到以下错误Ruby on rails Heroku部署:URI::InvalidURIError:错误的URI(不是URI?)://用户:pass@127.0.0.1/数据库名,ruby-on-rails,heroku,railtie,Ruby On Rails,Heroku,Railtie,我有一个带有Vue前端和rails后端的项目。它只是后端的一个非常简单的API,没有数据库或任何东西。它在本地运行良好,但现在我想在Heroku上部署它 然而,当我运行它时,我得到以下错误 -----> Detecting rake tasks ! ! Could not detect rake tasks ! ensure you can run `$ bundle exec rake -P` against your app ! and using th
-----> Detecting rake tasks
!
! Could not detect rake tasks
! ensure you can run `$ bundle exec rake -P` against your app
! and using the production group of your Gemfile.
! rake aborted!
! URI::InvalidURIError: bad URI(is not URI?): ://user:pass@127.0.0.1/dbname
...
...
/activerecord-6.0.2.1/lib/active_record/railties/databases.rake
基于各种SO帖子/Heroku文档,我已经尝试过:
-一切正常bundle exec rake-P RAILS\u ENV=production
- 在文件中添加
依赖项rake
- 删除文件中的
依赖项sqlite
- 从Gemfile.lock中删除捆绑的
链接到而不是
需要“rails/all”
,后者需要包括ActiveRecord在内的所有rails,您需要明确要求使用的rails:
require File.expand_path('../boot', __FILE__)
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
module Draw
class Application < Rails::Application
# You don't need this nonsense since you don't even have config/application.yml
# ENV.update YAML.load_file('config/application.yml')[Rails.env] rescue {}
# 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.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
# config.active_record.raise_in_transactional_callbacks = true
end
end
需要文件。展开路径('../boot',文件)
#需要Gemfile中列出的宝石,包括任何宝石
#您仅限于:测试、开发或:生产。
Bundler.require(*Rails.groups)
需要“轨道”
#选择您想要的框架:
需要“激活的\u模型/轨道连接”
需要“活动作业/轨道连接”
#需要“活动记录/轨道连接”
#需要“活动存储/引擎”
需要“控制器/轨道连接的操作”
要求采取“行动”\u邮递员/railtie
需要“操作\邮箱/引擎”
#需要“操作\文本/引擎”
需要“操作视图/轨道连接”
需要“操作电缆/发动机”
需要“链轮/系杆”
模块绘制
类应用程序
如果你不想使用ActiveRecord,你可以去掉/db
和/config/database.yml
您也不需要在gem文件中添加have
gem'rake'
,因为rails无论如何都依赖于它。而不是require'rails/all'
,后者需要包括ActiveRecord在内的所有rails,您需要明确要求您要使用的rails:
require File.expand_path('../boot', __FILE__)
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
module Draw
class Application < Rails::Application
# You don't need this nonsense since you don't even have config/application.yml
# ENV.update YAML.load_file('config/application.yml')[Rails.env] rescue {}
# 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.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
# config.active_record.raise_in_transactional_callbacks = true
end
end
需要文件。展开路径('../boot',文件)
#需要Gemfile中列出的宝石,包括任何宝石
#您仅限于:测试、开发或:生产。
Bundler.require(*Rails.groups)
需要“轨道”
#选择您想要的框架:
需要“激活的\u模型/轨道连接”
需要“活动作业/轨道连接”
#需要“活动记录/轨道连接”
#需要“活动存储/引擎”
需要“控制器/轨道连接的操作”
要求采取“行动”\u邮递员/railtie
需要“操作\邮箱/引擎”
#需要“操作\文本/引擎”
需要“操作视图/轨道连接”
需要“操作电缆/发动机”
需要“链轮/系杆”
模块绘制
类应用程序
如果你不想使用ActiveRecord,你可以去掉/db
和/config/database.yml
您也不需要在gem文件中添加have
gem'rake'
,因为rails无论如何都依赖于它。需要从项目中完全删除ActiveRecord的使用。正如,在一个新的应用程序中,这可以通过执行rails新应用程序的名称--skip active record--api
来完成,要对现有项目执行此操作,请参阅从项目中完全删除ActiveRecord的使用所需的。正如,在一个新的应用程序中,这可以通过执行rails新应用程序\u name--跳过活动记录--api
来完成,要对现有项目执行此操作,请参见我不确定要使用哪些rails,如果有的话。。。我甚至不确定railties是什么。我还注意到,由于这是Rails作为API的实现,我的应用程序控制器应该扩展ActionController::API
,而不是::Base
。我不知道为什么它是我指定的基础——创建应用程序时的api,即使只需要