- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我运行 rake db:seed
时,有些东西坏了!
我收到以下错误:
ray@ray-virtual-machine:~/ticketee$ rake db:seed rake aborted! SQLite3::ConstraintException: constraint failed: INSERT INTO "users" ("admin", "confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "last_sign_in_at", "last_sign_in_ip", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Tasks: TOP => db:seed (See full trace by running task with --trace)
这是我的 seeds.rb:
admin_user = User.create(:email => "admin@ticketee.com", :password => "password") admin_user.admin = true
admin_user.confirm!
Project.create(:name => "Ticketee Beta")
这是我的 gem list :
> source 'http://rubygems.org'
>
> gem 'rails', '3.1.0'
>
> # Bundle edge Rails instead:
> # gem 'rails', :git => 'git://github.com/rails/rails.git'
>
> gem 'sqlite3'
>
>
> # Gems used only for assets and not required
> # in production environments by default. group :assets do gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem
> 'dynamic_form' gem 'uglifier' end
>
> gem 'jquery-rails'
>
> # Use unicorn as the web server
> # gem 'unicorn'
>
> # Deploy with Capistrano
> # gem 'capistrano'
>
> # To use debugger
> # gem 'ruby-debug19', :require => 'ruby-debug'
>
> group :test, :development do # Pretty printed test output gem
> 'rspec-rails', '~>2.7' end
>
> group :test do gem 'cucumber-rails' gem 'capybara' gem
> 'database_cleaner' gem 'email_spec' gem 'factory_girl' end
>
> gem 'devise', '~> 1.4.3' gem 'cancan'
当我运行“rake db:seed --trace”时
ray@ray-virtual-machine:~/ticketee$ rake db:seed --trace
** Invoke db:seed (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:seed
rake aborted!
SQLite3::ConstraintException: constraint failed: INSERT INTO "users" ("admin", "confirmation_sent_at", "confirmation_token", "confirmed_at", "created_at", "current_sign_in_at", "current_sign_in_ip", "email", "encrypted_password", "last_sign_in_at", "last_sign_in_ip", "remember_created_at", "reset_password_sent_at", "reset_password_token", "sign_in_count", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.4/lib/sqlite3/statement.rb:108:in `step'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.4/lib/sqlite3/statement.rb:108:in `block in each'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.4/lib/sqlite3/statement.rb:107:in `loop'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.4/lib/sqlite3/statement.rb:107:in `each'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:192:in `to_a'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:192:in `block in exec_query'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb:171:in `exec_query'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/relation.rb:70:in `insert'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/persistence.rb:313:in `create'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/timestamp.rb:51:in `create'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/callbacks.rb:268:in `block in create'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:401:in `_run_create_callbacks'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/callbacks.rb:268:in `create'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/persistence.rb:294:in `create_or_update'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/callbacks.rb:264:in `block in create_or_update'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:399:in `_run_save_callbacks'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/callbacks.rb:264:in `create_or_update'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/persistence.rb:37:in `save'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/validations.rb:50:in `save'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:208:in `transaction'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:241:in `block in save'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/transactions.rb:240:in `save'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.9/lib/devise/models/confirmable.rb:38:in `block in confirm!'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.9/lib/devise/models/confirmable.rb:111:in `unless_confirmed'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/devise-1.4.9/lib/devise/models/confirmable.rb:35:in `confirm!'
/home/ray/ticketee/db/seeds.rb:12:in `<top (required)>'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `block in load'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:234:in `load'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/engine.rb:487:in `load_seed'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.0/lib/active_record/railties/databases.rake:299:in `block (2 levels) in <top (required)>'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/ray/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/ray/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/ray/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/home/ray/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => db:seed
你能告诉我我的代码中发生了什么吗?我是新手。
非常感谢您的宝贵时间。
最佳答案
我的猜测是您在调用时没有提供所有必填字段:
admin_user = User.create(:email => "admin@ticketee.com", :password => "password")
用户表的迁移文件是什么样的?您对模型用户进行了哪些验证?
关于ruby-on-rails - RoR: SQLite3::ConstraintException: 约束失败 =>rake db:seed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8677607/
我已经为精炼厂安装了一个博客引擎,它运行良好。 现在我生成了一些表字段更改的迁移(当然不是精炼厂或博客表),但我收到一个错误: == CreateBlogStructure: migrating ==
设置如下: 新建 Rails 应用程序,然后将此 test_rake.rake 放入 lib/tasks 中: task :testclass do HelloClass.hello end` 将
我觉得调用 bundle exec rake 或 bundle exec make 很奇怪:为什么不呢 bundle exec bundle exec rake 然后呢? 虽然我应该能够从 Rakef
我试图更好地了解 rake作品。我在 rake 网站上查看过它是如何工作的,但没有明确解释 rake搜索 Rakefiles 以及它在解决依赖项时所经历的步骤。有人能解释一下如何rake作品? 最佳答
我有一个构建系统,它由几个带有项目的子目录组成,其中每个子目录都有一个单独的 rakiefile(或几个 rakefiles)。没有顶级目录有一个 rakefile,它遍历所有子目录并通过以下方式调用
我想运行一个要求用户输入的 Rake 任务。 我知道我可以在命令行上提供输入,但我想询问用户是否确定他们想要继续执行特定操作,以防他们错误输入所提供的值之一到 Rake 任务。 最佳答案 像这样的东西
我在 this question 中遇到了相同的 heroku rake 问题(据我所知已解决) . 当我尝试修复(包括 require 'rake/dsl_definition' 上面的 requi
如何编写将捆绑安装然后 rake db:migrate 然后 rake db:seed 的 rake 任务。 namespace 'install' do 'bundle install' '
这可能是一种“插上电源了吗?”问题,但是在获得 Ubuntu 11.04 的默认 Rackspace 镜像之后。运行命令(以 root 身份) apt-get 安装 rake 因错误而失败 Readi
花了一些时间没有在 Rails 上编程,现在我“回来了”,事情出了问题。 我安装了 ruby 1.9.2-p0 并坚持使用 rails 3.0.1.Updated 所有 gems 和 bundle
我在让 dotCover 在 Albacore 中工作时遇到一些问题 exec使用相对路径的任务。 @xUnitRunnerPath = Pathname.new('../../Tools/xUnit
我正在尝试执行“rake db:migrate”,它给了我这个错误。 Andy:AcademyAir Andy$ rake db:migrate /Users/Andy/.rvm/gems/ruby-
我的 .bashrc 中有以下命令: alias mfigpdf='for FIG in *.fig; do fig2dev -L pdftex "$FIG" "${FIG%.*}.pdftex";
我希望能够发出命令 rake test:qunit并运行我们的 qunit 测试。这可能吗?可以在不打开浏览器窗口的情况下完成吗? 最佳答案 您可以将 PhantomJS 集成到 rake 中。 Ph
我不是一个 ruby 人,我正在使用 Ember.js 开发一个项目,我正在使用 Rake 管道来编译我的脚本。 # AssetFile $: true concat 'templates.
嗨,我正在做一些编码并试图 rake routes 这个错误信息出来了,我不知道该怎么办 rake aborted! Gem::LoadError: You have already activate
你好,我正在开发一个 rails 应用程序,每次我尝试运行任何 rake 命令时,我都会收到此错误 /usr/local/bin/rake:22:in load': cannot load such
我打电话 bundle exec cap staging demo:foo . demo:foo Cap 任务调用 Rake 任务,打印出 Rails.env . 但是...... Rails 任务正
相关的 travis-ci 构建位于: http://travis-ci.org/#!/NZOI/nztrain/builds/2046207 此时 db:migrate 或 db:test:prep
为什么我收到这个 Rake 错误: $ rake --version /Volumes/Data/sampablokuper/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/
我是一名优秀的程序员,十分优秀!