在rails项目中,我将模板放在public
文件夹中。但是当我想要渲染页面时,我得到的每个css都没有错误,并且css没有加载:
No route matches [GET] "/public/templates/assets/css/bootstrap.css"
我在公共文件夹中有以下目录:
public/templates/assets/css
我设置config.serve_static_assets = true
,但问题无法解决。
server log:
ActionController::RoutingError (No route matches [GET] "/assets/css/bootstrap.css
actionpack (4.1.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `c
actionpack (4.1.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `ca
railties (4.1.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.2) 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.1.2) lib/active_support/cache/strategy/local_cache_middleware
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.2) lib/rails/engine.rb:514:in `call'
railties (4.1.2) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/Ruby200-x64/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
C:/Ruby200-x64/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
答案 0 :(得分:0)
你的模板中应该有一些拼写错误:
/public/templates/assetes/css/bootstrap.css
应该是/public/templates/assets/css/bootstrap.css
。