在Rails

时间:2015-06-12 06:44:24

标签: ruby-on-rails ruby ruby-on-rails-4 import rake

我想将旧数据库导入rails中的新架构。 为此,我有.rake文件:

# /lib/tasks/project_name.rake: 

namespace :project_name do
  require Rails.root + "lib/tasks/importer"

  desc "Import old database, usage: rake project_name:import['old_database_name']"
  task :import, :oldDatabase, needs::environment do |t, args|
    args.with_defaults(oldDatabase: "import")

    oldDatabaseName = args.oldDatabse
    newDatabaseName = YAML::load(IO.read(Rails.root.join("config/database.yml")))[Rails.env]["database"]

    importer = Importer.new newDatabaseName, oldDatabaseName
    importer.execute
  end
end

但添加该文件后,我甚至无法使用任何rake命令。 以下是一些痕迹:

no implicit conversion of pathname into string
/Users/user/Desktop/rails/dis/lib/tasks/project_name.rake:2:in `block in <top (required)>'
/Users/user/Desktop/rails/dis/lib/tasks/project_name.rake:1:in `<top (required)>'
我是通过查看本教程来完成的:

http://www.frick-web.at/blog/import-old-database-in-new-schema-with-mysql-and-rails

1 个答案:

答案 0 :(得分:1)

printf "%.2f\t" "$((a+b*c))" > ofile.txt