# The tragedy of the tip of the iceberg Production
Started GET "/discount_service/assets/admin.js?body=1" for 127.0.0.1 at 2014-05-23 14:50:24 +0800actioncontroller:: Routingerror (No route matches [GET] "/discount_service/assets/admin.js"): Actionpack (4.0.0) lib/action_dispatch/ Middleware/debug_exceptions.rb:21:in ' call ' Actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb : 30:in ' call ' Railties (4.0.0) lib/rails/rack/logger.rb:38:in ' Call_app ' railties (4.0.0) lib/rails/rack/logger.rb:21: In ' Block in Call ' Activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in ' block in Tagged ' Activesupport (4.0 .0) lib/active_support/tagged_logging.rb:25:in ' tagged ' activesupport (4.0.0) lib/active_support/tagged_logging.rb : 67:in ' tagged ' railties (4.0.0) lib/rails/rack/logger.rb:21:in ' call ' Actionpack (4.0.0) lib/action_dispatch/ Middleware/request_id.rb:21:in ' call ' Rack (1.5.2) lib/rack/methodoverride.rb:21:in ' call ' Rack (1.5.2) lib/rack/ Runtime.rb:17:in ' call ' Activesupport (4.0.0) lib/active_support/cache/sTrategy/local_cache.rb:83:in ' call ' Rack (1.5.2) lib/rack/lock.rb:17:in ' call ' Actionpack (4.0.0) lib/action_dispatch/ Middleware/static.rb:64:in ' call ' Railties (4.0.0) lib/rails/engine.rb:511:in ' call ' Railties (4.0.0) lib/rails/ Application.rb:97:in ' call ' Rack (1.5.2) lib/rack/content_length.rb:14:in ' call ' Puma (2.6.0) lib/puma/server.rb:486: In ' Handle_request ' Puma (2.6.0) lib/puma/server.rb:357:in ' process_client ' Puma (2.6.0) lib/puma/server.rb:250:in ' Blo CK in Run ' Puma (2.6.0) lib/puma/thread_pool.rb:92:in ' call ' Puma (2.6.0) lib/puma/thread_pool.rb:92:in ' block in Spawn_ Thread
1.gemFile
There's no grop after Rails 4, remember.
# group:assets Dogem ' sass-rails ', ' ~> 4.0.0 ' gem ' coffee-rails ', ' ~> 4.0.0 ' gem ' uglifier ', ' >= 1.3.0 ' # end# Page render gem ' jquery-rails ' #这个gem ' Execjs ' # Remember this gem ' Turbolinks '
2. Inconfig/application.rb Remember, application file, don't be right.
Config.assets.precompile << proc.new do |path| If Path =~/\. (Css|js|scss|png|jpg|gif|json) \z/ full_path = Rails.application.assets.resolve (path). To_path App_assets_ path1 = Rails.root.join (' app ', ' assets '). To_path app_assets_path2 = Rails.root.join (' Public ', ' assets '). To_path app_assets_path3 = Rails.root.join (' Vendor ', ' assets '). To_path if Full_path.starts_with? app_assets_path1 true else if Full_path.starts_with? app_assets_path2 true else if Full_path.starts_ With? App_assets_path3 true else false end end End End
3. Tips config/environment/production.rb
Config.action_controller.relative_url_root = '/discount_service ' #是用来 practical ah Config.serve_static_assets = True # Compress JavaScripts and CSS. Config.assets.compress = True config.assets.js_compressor =: uglifier config.assets.css_compressor =: Sass
4. Finally, remember this.
Rails_env=production Rake Assets:precompile
Rails 4.0.0 Development environment Everything is OK, to build environment discovery cannot find CSS and JS