{"issue":{"state":"closed","created_at":"2011-10-08T18:07:07Z","updated_at":"2011-12-12T18:30:31Z","comments":21,"user":{"gravatar_id":"19cd304e508773ce1f739252758bc22a","id":109828,"url":"https://api.github.com/users/markembling","avatar_url":"https://secure.gravatar.com/avatar/19cd304e508773ce1f739252758bc22a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"markembling"},"body":"### Overview\r\n\r\nWhen deploying a Rails application (3.1.1) to a sub-path under Passenger, there is no way to provide this sub-path when precompiling assets. The result of this is that SCSS files have incorrect paths in them to images etc when the `image-url` and other helpers are used.\r\n\r\n### Brief Steps to Reproduce\r\n\r\nProduction environment is set up as follows for Apache/Passenger:\r\n\r\n    # Rails applications\r\n\r\n    RailsBaseURI /sample\r\n    <Directory /var/www/sample>\r\n        Options -MultiViews\r\n    </Directory>\r\n\r\n    RailsBaseURI /another-app\r\n    <Directory /var/www/another-app>\r\n        Options -MultiViews\r\n    </Directory>\r\n\r\n**Unfortunately the apps this affects (for me) are not public (neither the source or the running app), so I can't link directly to it. However it will be a problem common to all Rails apps deployed to a sub-path under Passenger using capistrano. The following steps (assuming a new app) should (hopefully) reproduce the problem.**\r\n\r\nAdd a background image to `app/assets/images` and add the following to `application.css.scss`:\r\n\r\n    body { background-image: image-url(\"bg.png\"); }\r\n\r\nMake sure the application is to be deployed using capistrano: \r\n\r\n`Gemfile`:\r\n\r\n    # Deploy with Capistrano\r\n    gem 'capistrano'\r\n\r\n`Capfile`:\r\n\r\n    load 'deploy' if respond_to?(:namespace) # cap2 differentiator\r\n    Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }\r\n\r\n    load 'config/deploy' # remove this line to skip loading any of the default tasks\r\n    load 'deploy/assets' \r\n\r\n`config/deploy.rb`\r\n\r\n    require \"bundler/capistrano\"\r\n    \r\n    set :application, \"SampleApp\"\r\n    set :repository,  \"git@git.example.com:SampleApp\"\r\n    set :scm, :git\r\n    set :branch, \"master\"\r\n\r\n    set :deploy_to,   \"/var/rails_apps/example\"\r\n    set :user, \"mark\"\r\n    set :deploy_via, :copy\r\n\r\n    role :web, \"server.example.com\"              # Your HTTP server, Apache/etc\r\n    role :app, \"server.example.com\"              # This may be the same as your `Web` server\r\n    # Commented out because its irrelevant to the sample.\r\n    #role :db,  \"your primary db-server here\", :primary => true # This is where Rails migrations will run\r\n    #role :db,  \"your slave db-server here\"\r\n\r\n    default_run_options[:pty] = true\r\n\r\n    # If you are using Passenger mod_rails uncomment this:\r\n    # if you're still using the script/reapear helper you will need\r\n    # these http://github.com/rails/irs_process_scripts\r\n\r\n    _cset :asset_env, \"RAILS_GROUPS=assets\"\r\n    _cset :assets_prefix, \"assets\"\r\n\r\n    namespace :deploy do\r\n      task :start do ; end\r\n      task :stop do ; end\r\n      task :restart, :roles => :app, :except => { :no_release => true } do\r\n        run \"#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}\"\r\n      end\r\n    end\r\n\r\n### End Result\r\n\r\nWhen the application is deployed, the assets will be precompiled on the server and the resulting stylesheet when sent to the browser will be missing the sub-path.\r\n\r\nDesired: `background-image:url(/sample/assets/bg-<whatever-hash>.png)`\r\nActual: `background-image:url(/assets/bg-<whatever-hash>.png)`\r\n\r\nThis is expected, because the precompilation process is not happening from within the context of the running application under Passenger, thus the sub-path is not known. The problem is that there seems to be no way to get this information into it.","assignee":null,"id":1853218,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[{"color":"e10c02","name":"asset pipeline","url":"https://api.github.com/repos/rails/rails/labels/asset+pipeline"}],"number":3259,"title":"Asset precompilation does not work when deploying under sub-path","html_url":"https://github.com/rails/rails/issues/3259","closed_at":"2011-12-12T17:32:23Z","url":"https://api.github.com/repos/rails/rails/issues/3259","milestone":{"state":"open","created_at":"2011-09-15T00:46:56Z","closed_issues":18,"due_on":null,"creator":{"gravatar_id":"d04d064616ae7fd752fdcb8daa5abdd6","id":52642,"url":"https://api.github.com/users/spastorino","avatar_url":"https://secure.gravatar.com/avatar/d04d064616ae7fd752fdcb8daa5abdd6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"spastorino"},"number":8,"title":"3.1.X","description":"","url":"https://api.github.com/repos/rails/rails/milestones/8","open_issues":12}},"action":"created","comment":{"created_at":"2011-12-12T18:30:31Z","updated_at":"2011-12-12T18:30:31Z","user":{"gravatar_id":"31c4a590d4c752f53038d786516c4c74","id":38320,"url":"https://api.github.com/users/jsanders","avatar_url":"https://secure.gravatar.com/avatar/31c4a590d4c752f53038d786516c4c74?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jsanders"},"body":"Very nice, thank you - will this go into 3.1.4?","id":3110182,"url":"https://api.github.com/repos/rails/rails/issues/comments/3110182"}}