3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails3 + Devise + Resque

Last updated at Posted at 2013-01-31

参考サイト

Resqueを利用したRailsでの非同期処理/バッチ処理

Resqueをはじめる その3 (Resqueを動かす)

Rakefile

Rakefile
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'resque/tasks'

MyApp::Application.load_tasks

# Fix resque error. 
# ref: https://gist.github.com/1316470
task "resque:setup" => :environment do
  ENV['QUEUE'] ||= '*'
  # for redistogo on heroku http://stackoverflow.com/questions/2611747/rails-resque-workers-fail-with-pgerror-server-closed-the-connection-unexpectedl
  Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
end

route.rb

Deviseを使っている場合は、以下のように書くと、admin認証されたユーザだけにresqueのページを閲覧させることが出来ます。

route.rb
require 'resque/server'

MyApp::Application.routes.draw do
... 
  #
  # Resque
  #
  authenticate do
    mount Resque::Server.new, :at => "/admin/resque"
  end
end
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?