我如何使用RAILS_ENV =生产db:schema:加载capistrano& MySQL的?

时间:2013-08-20 20:06:37

标签: ruby-on-rails capistrano

我正在学习rails并尝试首次部署测试应用程序。我一直在关注capistrano指南。当我运行RAILS_ENV=production db:schema:load时,我收到此错误,我不确定是什么错误。

-------不再适用(请参阅更新2)

path/to/rails/app$ rake RAILS_ENV=production db:schema:load --trace
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
missing :action
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:233:in `default_controller_and_action'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/actionpack-
......
......
......
......
......

/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:schema:load => environment

------------

这是我的database.yml文件

    # SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: mysql2
  database: test
  pool: 5
  username: username
  password: password
  socket: /var/run/mysqld/mysqld.sock
  timeout: 5000

谁能看到我做错了什么?感谢。

更新

我的routes.rb文件

Blog::Application.routes.draw do

  resources :users do
    resources :posts, except: [:index]
  end
  resources :posts, only: [:index]
  resources :sessions, only: [:create, :destroy]

  get "/signin" => "sessions#new"
  delete "/signout" => "sessions#destroy"
  root "static_pages#index"

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  # root 'welcome#index'

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end

更新2:

因此,根据以下建议,我逐一评论了我的路线,但我仍然得到了错误。我查看了应用程序目录,并将我的应用程序文件与“当前”,“发布”和“共享”文件夹混合在一起,所以我很确定我的deploy.rb文件有问题。我修复了deploy.rb文件并从头开始重新启动了部署过程。但现在我得到了一个新的错误。

path/to/rails/app$ rake RAILS_ENV=production db:schema:load --trace
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:632:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'

有什么建议吗?感谢

0 个答案:

没有答案