How do I run a rake task from Capistrano?

A little bit more explicit, in your \config\deploy.rb, add outside any task or namespace: namespace :rake do desc “Run a task on a remote server.” # run like: cap staging rake:invoke task=a_certain_task task :invoke do run(“cd #{deploy_to}/current; /usr/bin/env rake #{ENV[‘task’]} RAILS_ENV=#{rails_env}”) end end Then, from /rails_root/, you can run: cap staging rake:invoke task=rebuild_table_abc

Rails how to run rake task

You can run Rake tasks from your shell by running: rake task_name To run from from Ruby (e.g., in the Rails console or another Rake task): Rake::Task[‘task_name’].invoke To run multiple tasks in the same namespace with a single task, create the following new task in your namespace: task :runall => [:iqmedier, :euroads, :mikkelsen, :orville] do … Read more

puts vs logger in rails rake tasks

Put this in application.rb, or in a rake task initialize code if defined?(Rails) && (Rails.env == ‘development’) Rails.logger = Logger.new(STDOUT) end This is Rails 3 code. Note that this will override logging to development.log. If you want both STDOUT and development.log you’ll need a wrapper function. If you’d like this behaviour only in the Rails … Read more

How to run rake tasks from console?

Running your Rake tasks requires two steps: Loading Rake Loading your Rake tasks You are missing the second step. Normally this is done in the Rakefile, but you have to do it manually here: require ‘rake’ Rails.application.load_tasks # <– MISSING LINE Rake::Task[‘my_task’].invoke

Rails and PostgreSQL: Role postgres does not exist

Actually, for some unknown reason, I found the issue was actually because the postgresql role hadn’t been created. Try running: createuser -s -r postgres Note that roles are the way that PostgreSQL maintains database permissions. If there is no role for the postgres user, then it can’t access anything. The createuser command is a thin … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)