Ruby on Rails: How can I add a css file with rails project?

邮差的信 提交于 2019-12-01 14:45:00

Rails is likely consolidating all your css files into one that it is calling assets/all.css

Consider using the free plug-ins firebug + firepath to further characterize the problem. This common combo of tools will help you to interrogate web page elements and see the css that is contributing to their display.

Copy cake.generic.css to the folder public/assets/, if not exists make directory first.

then add this to you erb <%= stylesheet_link_tag "cake.generic" %>

2nd question: How can i set the public folder for stylesheets and javascripts ?

Just put all you images, js and css file under 'public/assets/' and then include them in the erb pages

3rd question: It looks that app/assets folder is set for css and js files ?

Yes, 'app/assets/stylesheets/' for css and scss file and 'app/assets/javascripts' for js and coffeescript file

You can get more info here: http://guides.rubyonrails.org/asset_pipeline.html#how-to-use-the-asset-pipeline

Hope this work for you:)

Your Style sheet should be placed in the following directory \public\stylesheets from your root project and also if you want to specify different location provide an absolute path inside stylesheet_link_tag("/public/yourfolder/test.css")

I had similar issue, but my fix was to make sure the css is under app/assets/stylesheets/ and I had to add the below line to the application.css file (my css file is named custom.css)

@import 'custom'

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