Rails主动管理css与Twitter Bootstrap css冲突 [英] Rails Active Admin css conflicting with Twitter Bootstrap css

查看:146
本文介绍了Rails主动管理css与Twitter Bootstrap css冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Rails的资产管道有点陌生,所以我可能做错了。我尝试为我的后端应用程序使用Active Admin和twitter启动css。



我将bootstrap.css添加到 / app / assets / stylesheets ,然后还添加了:

  // = require bootstrap 



到application.css - 然后我对本地资源进行了预编译。



工作正常,但一些造型不是准确地来,我认为这是因为活动管理员的CSS覆盖它。



我的理解是,应用程序编译css资产进入应用程序css公共资产,应用程序在运行时使用该文件。



我需要以某种方式将两者分开,并使用 twitter bootstrap css 作为前端的主要css,也许不要



这是最好的方法是什么?



http://railscasts.com/episodes/284-active-admin



将视频中的信息转移到answer

p>

在application.css中删除:

  * = require_tree。 

对于rails 4, Jiten K 建议将它添加到 production.rb

  config.assets.precompile + = ['active_admin.css'] 

但是,对该答复的评论之一说,这不是必需的。我到目前为止还不需要它。


I'm somewhat new to the Rails asset pipeline so I might be doing something wrong. I'm trying to use Active Admin for my backend and twitter bootstrap css for my front end application.

I added the bootstrap.css to /app/assets/stylesheets then also added:

//= require bootstrap

to application.css - then I did a precompile of the assets locally

It seems to work fine but some of the styling isn't coming through exactly and I think it's because active admin's css is overriding it.

My understanding is that the application compiles the css assets into the application css public asset and the application uses that file when running.

I need to somehow separate the two and make it use twitter bootstrap css as the main css on the front end and maybe tell it not to use active admin's css files on the front end.

What's the best way to do this?

解决方案

Have you watched the RailsCasts video on using ActiveAdmin? In the video, Ryan shows you how to prevent the ActiveAdmin CSS from stepping on your main app CSS.

http://railscasts.com/episodes/284-active-admin

Moving info from Video into answer

In the application.css you remove:

*= require_tree .

For rails 4, Jiten K suggests adding this to production.rb:

config.assets.precompile += ['active_admin.css']

However one of the comments on that SO answer says this is not needed. I have not needed it so far.

这篇关于Rails主动管理css与Twitter Bootstrap css冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆