问题
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