Tag: rake

Rake db:迁移错误“不知道如何构建任务”

我有一个表,我在需要小数位的字段上使用整数,所以我试图创建一个迁移,将字段类型从整数更改为float / real。 我的数据库是sqllite3,我正在使用rails3。 我跑了 rails生成迁移ChangeMeasureColumnOnIngredients 创建初始迁移文件,然后将类更新到 class ChangeMeasureColumnOnIngredients <ActiveRecord :: Migration def self.up change_column:ingredients,:measure,:real 结束 我运行rake db:migrate并返回正常。 当我通过我的rails应用程序插入一个值时,它没有返回小数位。 我开始认为许多rails不知道’real’是什么作为数据类型,因此我将迁移更改为 change_column:ingredients,:measure,:float 然后我跑了 rake db:migrate change_measure_column_on_ingredients 现在我收到以下错误 c:\ Ruby192 \ rails3rc> rake db:migrate change_measure_column_on_ingredients(在c:/ Ruby192 / rails3rc中)rake aborted! 不知道如何构建任务’change_measure_column_on_ingredients’C:/Ruby192/lib/ruby/1.9.1/rake.rb:1720:in []’ C:/Ruby192/lib/ruby/1.9.1/rake.rb:2040:in invoke_task’C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:top_level中的block (2 levels) in top_level’ C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019:in每个’C:/Ruby192/lib/ruby/1.9.1/rake.rb:2019: block in top_level’ C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in中的block in top_level’ C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in standard_exception_handling’C:/Ruby192/lib/ruby/1.9.1/rake.rb:2013:在top_level’ C:/Ruby192/lib/ruby/1.9.1/rake.rb:1992:in运行’C:/ […]

rake db:migrate(mysql)

可能重复: 库未加载:尝试使用mysql2 gem在OS X 10.6上运行’rails server’时出现libmysqlclient.16.dylib错误 为什么我得到这个错误? 什么意思? 我已经安装了mysql2 gem,“sudo gem install mysql2” 的Gemfile: gem ‘mysql2′ 〜:rake db:migrate –trace rake aborted! dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle Reason: image not found – /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9 /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require’ /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require’ /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each’ /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `require’ /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each’ /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require’ /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:122:in `require’ /Users/leonardo/dev/myproject/config/application.rb:7 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require’ […]

错误:’rake / rdoctask’已过时且不再受支持

出乎意料的是,我开始收到以下错误消息: (in /Users/me/.rvm/gems/ruby-1.9.3-p125@mysql2/gems/rails-0.9.5) rake aborted! ERROR: ‘rake/rdoctask’ is obsolete and no longer supported. Use ‘rdoc/task’ (available in RDoc 2.4.2+) instead. /Users/me/.rvm/gems/ruby-1.9.3-p125@mysql2/gems/rails-0.9.5/Rakefile:3:in `’ 当我做rails s(在我的开发环境终端–Mac Mountain Lion)。 这个应用程序正在生产中,所以我去了生产环境,做了一个捆绑显示,并修改了我的Gemfile,以对这些gems版本进行编码。 这就是我现在在我的本地开发环境中所产生的内容(产生错误消息的原因)。 actionmailer (3.2.3) actionpack (3.2.3) activemodel (3.2.3) activerecord (3.2.3) activeresource (3.2.3) activesupport (3.2.3) annotate (2.4.1.beta1) arel (3.0.2) bcrypt-ruby (3.0.1) bootstrap-datepicker-rails (0.6.15) bootstrap-sass (2.0.2) builder (3.0.4) bundler (1.1.3) coffee-rails […]

rake db:create generated“如果你手动设置字符集,请确保你有匹配的排序规则”错误

我在版本2.3.8中获得了一个rails项目。 当我试图运行rake db:create时,发生以下错误。 Couldn’t create database for {“encoding”=>”utf8”, “username”=>”root”, “adapter”=>”mysql”, “database”=>”claims_test”, “host”=>”localhost”, “password”=>”root”, “socket”=>”/var/run/mysqld/mysqld.sock”}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation) 我手动创建了DB并尝试运行该应用程序。 现在我收到了这个错误。 /!\ FAILSAFE /!\ Tue May 10 20:38:48 +0530 2011 Status: 500 Internal Server Error uninitialized constant MysqlCompat::MysqlRes 我尝试了Webrick和mongrel,这似乎是同样的原因。

上传到Heroku DB rake:迁移问题

有一个heroku上传问题。 对于RoR来说还是新手,请原谅初学者的问题。 我正在关注Ruby on Rails教程(http://ruby.railstutorial.org),在脚手架之后,我输入heroku rake db:migrate并得到以下错误: 耙子流产了! 请安装postgresql适配器: gem install activerecord-postgresql-adapter (pg不是bundle的一部分。将它添加到Gemfile。) 任务:TOP => db:migrate => db:load_config(通过使用–trace运行任务来查看完整跟踪) 第一次,没问题,但这次我收到了这个错误。 有任何想法吗?

Heroku rake db:migrate导致错误R13(附加错误) – >无法附加到进程

我在heroku上有一个rails应用程序,我无法运行我最新的数据库更改。 运行heroku run rake db:migrate给了我 Running `rake db:migrate` attached to terminal… up, run.3167 ! Heroku client internal error. ! Search for help at: https://help.heroku.com ! Or report a bug at: https://github.com/heroku/heroku/issues/new Error: Operation timed out – connect(2) (Errno::ETIMEDOUT) Backtrace: /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:40:in `initialize’ /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:40:in `open’ /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:40:in `block in start’ /usr/local/heroku/ruby/lib/ruby/1.9.1/timeout.rb:68:in `timeout’ /Users/gregg/.heroku/client/lib/heroku/client/rendezvous.rb:31:in `start’ /Users/gregg/.heroku/client/lib/heroku/command/run.rb:132:in `rendezvous_session’ /Users/gregg/.heroku/client/lib/heroku/command/run.rb:119:in `run_attached’ […]

Rails:让这个rake任务知道它在测试环境中

我在lib/tasks文件夹中定义了以下rake任务: namespace :db do namespace :test do task :prepare => :environment do Rake::Task[“db:seed”].invoke end end end 现在,当我运行rake db:test:prepare时,这样做是为了测试数据库的种子。 我这样做是因为我有一些必须存在的基本记录才能让应用程序运行,所以它们不是可选的,也不能真正被嘲笑。 另外,我有一个在开发和生产中使用S3进行资产存储的模型,但我不希望它使用S3进行测试。 我在模型中设置了一个方法,如果Rails.env.test?存储路径从S3更改为本地Rails.env.test? 但是,这不起作用。 我想知道rake任务是否知道它被调用的环境,而事实certificate它不是。 我把它放在我的seeds.rb文件的顶部: puts “Environment Check: Rails Environment = #{Rails.env}” 果然,当任务运行时,会打印出来: Environment Check: Rails Environment = development 那么,我怎样才能重做这个rake任务,以便当它播种测试数据库时它知道它正在为测试数据库播种?

bundle exec不能与crontab一起使用

我正在尝试使用crontab执行以下shell脚本: #!/bin/sh cd /mnt/voylla-production/current bundle exec rake maintenance:last_2_days_orders bundle exec rake maintenance:send_last_2_days_payment_dropouts crontab条目是 0 16 * * * /mnt/voylla-production/releases/20131031003111/voylla_scripts/cj_4pm.sh 我在邮件中收到以下错误消息: /mnt/voylla-staging/current/voylla_scripts/cj_4pm.sh: line 3: bundle: command not found /mnt/voylla-staging/current/voylla_scripts/cj_4pm.sh: line 4: bundle: command not found 我手动运行命令时没有收到错误。 不知道这里发生了什么。 请有人指出。 谢谢

rake db:migrate生成“rake aborted! 找不到表“错误

我是Rails的新手,我正在为我的雇主构建一个简单的项目跟踪应用程序。 我一直在我的Mac上开发应用程序并将其推送到github。 我只是设法将我的github repo克隆到我公司防火墙后面的一个Windows框中,希望让同事们试用这个应用程序。 但是当我去rake db:migrate来初始化windows框中的数据库时,我收到以下错误消息: $ rake db:migrate –trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! Could not find table ‘projects’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/connection_adapters/sqlite3_adapter.rb:29:in `table_structure’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/faker-0.3.1/lib/extensions/object. rb:3:in `returning’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/connection_adapters/sqlite3_adapter.rb:28:in `table_structure’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/connection_adapters/sqlite_adapter.rb:228:in `columns’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/base.rb:1271:in `columns’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/base.rb:1279:in `columns_hash’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/base.rb:1578:in `find_one’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/base.rb:1569:in `find_from_ids’ c:/RubyonRails/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_reco rd/base.rb:616:in `find’ […]

使用rake db:migrate命令和mysql在Rails中创建表的PRIMARY KEY问题

我的rails版本是4.0.0,我的mysql版本是Ver 14.14 Distrib 5.7.9,适用于Win64(x86_64)。 我正在运行一个旧版本的rails,因为我正在根据我之前的问题获得与mysql的一些冲突。 (查看Kalelc批准的回答我的追索权) 跑步时 rake db:migrate 我收到以下错误 == CreateUsers: migrating ==================================================== — create_table(:users) rake aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead: CREATE TABLE `users` (`id` int(11) DEFAULT NULL […]