Rails -Namespace Css Not Working

*爱你&永不变心* 提交于 2019-12-23 05:37:28

问题


I am trying to implement a admin namespace into my web application .It is working fine on my local machine but when I am trying to deploy the application none of my css is working. I tried

rake assets:precompile

I have restarted the server .My structure looks like this

  • app

    • assets

      • stylesheets

        . application.css

        • admin

          • my_admin.css

The same structure is with Javascripts.In my layout file I have used

 <%= stylesheet_link_tag    "admin/my_admin" %>
 <%= javascript_include_tag "admin/my_admin" %>

When I run my application it works fine but none of my css nor javascript is there ..In my Browser inspector it is saying my_admin css and javascript not found.Any help??


回答1:


In production you likely have

config.assets.compile = false

in your config/environment/production.rb. This prevents the asset pipeline from compiling scripts on demand in production as it does in development.

You need to specify any .js or .css assets you want precompiled which are not application.js or application.css.

Adding the following to your config/environment/production.rb

config.assets.precompile += ["admin/my_admin.css", "admin/my_admin.js"] 

and running rake assets:precompile should put those compiled assets into public/assets for you.



来源:https://stackoverflow.com/questions/12217852/rails-namespace-css-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!