- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近刚刚将我的应用程序部署到 Heroku,但是当我运行 Heroku run rake db:migrate 时,出现以下错误。
NameError: uninitialized constant User
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:261:in `const_get'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:261:in `block in constantize'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:259:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:259:in `inject'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/inflector/methods.rb:259:in `constantize'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise.rb:292:in `get'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/mapping.rb:81:in `to'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/mapping.rb:76:in `modules'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/mapping.rb:93:in `routes'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/mapping.rb:160:in `default_used_route'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/mapping.rb:70:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise.rb:326:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise.rb:326:in `add_mapping'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/rails/routes.rb:238:in `block in devise_for'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/rails/routes.rb:237:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/devise-3.5.6/lib/devise/rails/routes.rb:237:in `devise_for'
/app/config/routes.rb:4:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:434:in `instance_exec'
/app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:434:in `eval_block'
/app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/route_set.rb:412:in `draw'
/app/config/routes.rb:1:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:16:in `reload!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/file_update_checker.rb:75:in `call'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/file_update_checker.rb:75:in `execute'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:27:in `updater'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:328:in `require_environment!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:457:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
下面是我设计的创建用户表(20160403200237_devise_create_users.rb)
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.inet :current_sign_in_ip
t.inet :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps null: false
end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
# add_index :users, :confirmation_token, unique: true
# add_index :users, :unlock_token, unique: true
end
end
下面是一个名为 (20160403200704_add_email_to_users.rb)
的添加列class AddEmailToUsers < ActiveRecord::Migration
def change
add_column :users, :playlist, :text
end
end
下面是用户模型(user.rb)
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
serialize :playlist, Hash
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
只有当我在 heroku 中运行 rake db:migrate 时,我才会收到这些错误。当我在本地运行时,即使在生产模式下使用 rails s -e production 也能顺利运行。我真的可以在这方面使用帮助。谢谢!
下面是我的 Gemfile
source 'https://rubygems.org'
gem 'figaro'
gem 'bootstrap-sass'
gem 'font-awesome-sass'
gem 'devise'
gem 'rails_12factor', group: :production
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
最佳答案
首先将你的 gem pg
和 gem rails_12factor
移动到 :production group
group :production do
gem 'pg'
gem 'rails_12factor'
end
本地运行以更新 gemlock 文件 bundle install
。然后推送到 git push heroku master
。
链接:PG RESET
要删除数据库,如果您使用的是 SHARED_DATABASE_URL:
heroku pg:reset DATABASE
在 pg:reset
之后
! WARNING: Destructive Action
! This command will affect the app: NAME OF YOUR HEROKU APP
! To proceed, type "NAME OF YOUR HEROKU APP" or re-run this command with --confirm NAME OF YOUR HEROKU APP
要重新创建其中没有任何内容的数据库:
heroku run rake db:migrate
您可以通过执行以下操作将最后两个合并为一个操作:
heroku run rake db:setup
关于ruby-on-rails - 名称错误 : unitialized constant User for rake db:migrate in Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36391110/
因此,我正在使用 rails(ruby 1.9.3p392、rails 3.2、sqlite3 db)并尝试将无处不在的博客教程代码部署到“生产”服务器(apache、passenger、ubuntu
我继承了一个项目,该项目设置为使用 Entity Framework 在新数据库上设置数据库架构。 该项目最初有两个不同的文件夹——默认的/Migrations 文件夹和另一个文件夹——带有 DbMi
我在我的 Nest 应用程序上运行这行代码: import * as typeOrm from "../node_modules/typeorm/index"; bootstrap(){ //
我需要像下面的代码一样创建一个外键: Create.ForeignKey().FromTable("TCGDocFiscalOpMedItem").ForeignColumn("IDCabecalho
如何从扩展 Migration 的类的 Up(或 Down)方法中获取迁移正在操作的数据库的名称 public class BaseMigration : Migration { public
我们已将迁移添加到我们的xamarin表单项目中,此后我们就无法将其部署到iOS设备上。它可以在模拟器上正常运行,但在部署到设备时会因AOT错误而失败。 这似乎是一个在网络上广泛传播的话题,但是到目前
我正在尝试自己研究 Fluent Migrator,但我遇到了一个问题,我需要更改由 Fluent Migrator 创建的表的结构,这意味着我使用以下代码创建了一个名为 user 的表 [Migr
我正在使用 PostgreSQL、Rails 3.1.3 和 Ruby 1.9.3。我正在努力使用 db:migrate 概述 here . 这是我在终端中看到的: funkdified@funkdi
我决定使用 gorm作为我的 ORM。我想使用 golang-migrate/migrate 进行迁移因为,看起来 GORM 没有版本化迁移文件。我宁愿使用 CLI 进行迁移,而不是使用自动迁移。 我
我正在针对现有 SQL Server 数据库设置 EF Core 3.1.3 迁移。 这是我到目前为止所做的: 从现有数据库搭建我的模型。 添加 InitialCreate 迁移。 删除 Initia
我正在玩 Entity Framework 和持续构建。到目前为止,通过使用 migrate.exe 和适当的参数,我能够毫无问题地运行迁移或一系列迁移。 但是,我在尝试让 migrate.exe 踢
我正在使用包管理器控制台向我的数据库添加迁移,但由于某种原因它只是卡住并且什么也不做。停止它并继续使用它的唯一方法是使用任务管理器关闭 Visual Studio。这是一个已知问题吗? 最佳答案 我不
我在sequelize上运行帮助命令,发现有两个不同的命令具有相同的描述: $ sequelize help:migration:create Sequelize [Node: 6.9.5, CLI:
在这里,我使用的是 Microsoft Azure。 其中,我正在尝试使用开源 DocumentDB 数据迁移工具将数据从各种来源导入 Microsoft Azure DocumentDB,包括 JS
我是 Laravel 的新手。 我正在开发 Laravel 版本 6。 我已经创建了迁移。 第一次运行良好,但如果我更改迁移文件中的某些内容,然后运行 php artisan migrate它显示
我已经使用 NuGet 安装了 Migrator.NET,但是当我尝试使用 MSBuild 运行迁移时,出现以下错误。我看到它在访问 Migrator.Framework 程序集时遇到问题,但我不确定
我有一个基于 miguel flask tutorial 的网络应用程序 所以我将 sqlalchemy-migrate 用于数据库,现在我应该在迁移中使用 Alembic 我该如何配置?有什么方法可
我已经尝试执行 cli 命令 ./doctrine generate-migrations-diff 并在正确的文件夹中正确创建了一个版本文件。 消息是:generate-migrations-dif
可以定义存储迁移的多个路径: doctrine_migrations.yaml doctrine_migrations: migrations_paths: 'App\Migr
我在我的 .Net 应用程序中使用 Fluent Migrator 1.6.2。 对于数据库的上迁移或下迁移,需要通过命令行传递汇编文件(迁移类所在的数据库工程的dll文件)来执行Migrate.ex
我是一名优秀的程序员,十分优秀!