简体   繁体   中英

serving a static page built with skel on Rails

I found a nice template online and want to use it for my rails app homepage. I decided to use the high voltage gem and read through its readme. I managed to get the routing right but I could not find the appropriate path/folder for the numerous asset (css, js, svgs and sass) files which come inside the template zip file, and which obviously make it look nice.

I tried putting them into the assets folder of my rails app, which got some of the "features" working, but svgs and images didn't display... and it screwed my existing pages. Reading through the Rails documentation I then tried storing the template assets into the vendor folder, which did not work either.

Where should I store the assets for my template-inspired homepage for them not to screw the appearance of my normal/app pages? Which paths should I use in my html to call them?

If you have troubles with images, take a look at image references in the template source. You can see a reference to image like this :

background-image: url('images/top-1280.svg')

which would not serve this image in Rails.

I would suggest to find and replace all the image references in your css (or scss) files.

Try this :

background-image: url(image-path('top-1280.svg'));

which is the proper way for Rails 4.

The differences: in Rials you have a helper method "image-path" and you do not prefix the image file with directory name.

It is important to check in your "app/assets/stylesheets/appilcation.css" if there are lines like:

 *= require_tree .
 *= require_self

Now about Font Awesome : I see that in this theme you are about to use Font Awesome. I would suggest using the gem for Rails:

In your Gemfile:

gem 'font-awesome-sass'

I think the theme you have chosen is very nice. Thank you for sharing it, it will be useful for my current project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM