问题描述:

I just purchased a wrap bootstrap template and tried to use it on a ruby on rails app. I pasted all its images files under my local /app/assets/images folder, js files under /app/assets/javascripts , html files under /app/views and all css files under /app/assets/stylesheets.

When I just clicked the html file it's working correctly. But when I tried to run localhost, it just showed the basic html files without any pictures or font styles.

网友答案:

Yes. I ran into this Exact problem myself recently. The way I solved this was to:

Open the downloaded WrapBootstrap template contents (example mine had various pages but two main folders Documentation and HTML). Inside of the HTML folder there should be a sub folder named assets. Copy and paster this entire folder into you public folder.

The next step which had me beating my head into the table was when you use a page of the HTML in the template the CSS and JS is all referenced in a similiar way example:

      <link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">

      <script type="text/javascript" src="assets/js/plugins/layer-slider.js"></script>

But when you place it into your application.html.erb file you need to make sure you place a leading / (slash) in front of assets like so:

        <link rel="stylesheet" href="/assets/plugins/bootstrap/css/bootstrap.min.css">

      <script type="text/javascript" src="/assets/js/plugins/layer-slider.js"></script>

So that now the assets are being referenced from an absolute path rather than a relative one.

相关阅读:
Top