Rails 3.1.3 on Heroku: (No route matches [GET] “/assets/rails.png”)

后端 未结 3 1447
南方客
南方客 2020-12-19 16:27

I\'ve installed a few basic apps on Heroku without problem, and this one (Rails 3.1.3) seemed fine in that it showed Rails welcome page

public/index.html.         


        
相关标签:
3条回答
  • 2020-12-19 17:06

    To get lazy initiation working with thin (on heroku) with rails 3.2.3 I had to do:

    In config/application.rb:

    if defined?(Bundler)
      # If you precompile assets before deploying to production, use this line
      # Bundler.require(*Rails.groups(:assets => %w(development test)))
      # If you want your assets lazily compiled in production, use this line
      Bundler.require(:default, :assets, Rails.env)
    end
    
    ...
    
    
    module Romulo
      class Application < Rails::Application
    
    ...
    
        # Enable the asset pipeline
        config.assets.enabled = true
    
        # Version of your assets, change this if you want to expire all your assets
        config.assets.version = '1.0'
    
        # get precompilation working on heroku:
        config.assets.initialize_on_precompile = true
    
        config.serve_static_assets = false
      end
    end
    

    In config/environments/production.rb:

    # Compress JavaScripts and CSS
    config.assets.compress = true
    
    # Don't fallback to assets pipeline if a precompiled asset is missed
    config.assets.compile = true
    
    # Generate digests for assets URLs
    config.assets.digest = true
    

    No need to precompile assets.

    0 讨论(0)
  • 2020-12-19 17:09

    It looks like you may not have precompiled your assets before you pushed to Heroku, try:

    rake assets:precompile
    git add .
    etc etc
    

    I think that should help. For more information, see here: http://devcenter.heroku.com/articles/rails31_heroku_cedar

    0 讨论(0)
  • 2020-12-19 17:19

    No need to precompile and clutter your git!

    heroku will precompile your assets

    with rails 3.1.x you added this to application.rb

    config.assets.initialize_on_precompile = false
    

    UPDATE 16th july2012

    also rails 3.2.x

    it seems to be problem with ActiveRecord and database.yml ! If you don't use regular database, but use MongoDB, you will not need the above. However, if you do, you'll need to disable the initilize, as activerecord reads database tables when initializing, but database is not available at precompile phase at heroku.

    with MongoDB it is not necessary.

    /UPDATE

    rails 3.2.x : Have a look at the top of application.rb. The OMA comments are mine, added for clarity

    if defined?(Bundler)
      # If you precompile assets before deploying to production, use this line
      "OMA - comment this line"
      #Bundler.require(*Rails.groups(:assets => %w(development test)))
      # If you want your assets lazily compiled in production, use this line
      "OMA - uncomment this line"
      Bundler.require(:default, :assets, Rails.env)
    end
    
    0 讨论(0)
提交回复
热议问题