Pergunta

I have a simple Rails app with Resque server mounted in routes.rb as

require 'resque/server'
require 'resque_scheduler'


    MyApp::Application.routes.draw do

        authenticate :user do
            mount Resque::Server.new, :at => "/tasks"
        end
        ...
        ...

Mounted the app in routes to use devise based authentication. In production however, the assets are not loaded for the Resque server while the assets for the main Rails app load properly.

Foi útil?

Solução

After looking around this worked for me with nginx and thin:

require 'resque/server'

class SecuredResqueServer < Resque::Server
  set :static, true
  set :root, Resque::Server.root
end

The routes file look as follows:

    require 'resque/server'
    require 'resque_scheduler'
    require './app/secured_resque_server'


    MyApp::Application.routes.draw do
    ...
    ...
    authenticate :user do
        mount SecuredResqueServer.new, :at => "/tasks"
    end
    ...
    ...

and changing

config.action_dispatch.x_sendfile_header = "X-Sendfile"

in production.rb to

config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

Thirdly, in some cases nginx is configured for rails as follows:

server{
        ...
        ...
        location ~*\.(jpeg|jpg|gif|png|ico|css|bmp|js)$ {
                root /PATH_TO_APP/public;
        }
        ...
        ...
      }

Where PATH_TO_APP is the path of the application root directory. Such location declaration prevents assets to be loaded from any other location for a mounted rake app or engine. This therefore, needs to be removed/commented out.

Lastly, don't forget to do a Ctrl+F5 to force reload the page :)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top