add onepager with different assets to railsapp - ruby-on-rails

I downloaded a onepager from the internet. This includes a html file with a lot of assets (seperate css, javascript and image files). It is a bootstrap theme so I know I can delete those css files from bootstrap.
What is the most clean way to implement this? I don't want those assets loaded when people are using the app itself. It is only needed for the landing page.
I know I can put it in the vendor folder. Problem here is still everything gets loaded.
Can somebody put me on the right track?

Related

jstree and Rails asset pipeline

I am using the jstree (https://www.jstree.com/) jQuery library. Works fine in development but in production all the standard background CSS breaks. The css calls the background icons from /app-assets/32px.png etc. These files are in my /app/assets/images and even added them to my pre-compile but none of them load (throw 404 errors).
I suspect the issue is that I deploy to production Rails is pre-compiling the images and when the jstree css calls url("32px.png") the server calls /app-assets/32px.png which will always fail because the server is expecting the /app-assets/32px-xxxxxxxxxxxxxxxx.png precompiled asset pipeline url.
I can manually dump the icon files in the public folder and hack the css but the JS seem to still trigger code for the old path. Can I get JS tree to reference the Rails asset pipeline urls?
The ended up being the CSS which calls for the background to be url("32px.png") and in the Rails world that is relative to the pre-compiled CSS that is under /assets/...
I placed my jstree images in the static /public folder and then changed the CSS to url("/32px.png") so that jstree loads them absolute from root.
There is an option to use image-url("32px.png") but the jstree JS fails when it tried to load the images as it tries to still load the relative path and I saw some double loading of the image files etc. I gave up on that and opted for the first solution.
Hope this helps someone down the road.

Ruby on rails resource issue

I have a project that includes lots of js, css and png. I couldn't divide them into javascripts and stylesheets folders. For example I have plugin1 folder it includes js and css files and I want to keep them together in same folder. Could you help me?
If you want to use the rails assets pipeline Im nearly certain that you'll have to put the files into the correct location as described in the ruby guides. Rails will then pull all this together to create, for example, the js file. It would be, I imagine, a big job to change this set up.
I guess if your set on keeping the folders the same you'll just have to point to the JavaScript/CSS files the traditional way through the header/footer with links to the file locations.
The rails guides explain the asset pipeline pretty well, and are a good place to start digging around further.
Good luck!

JS and CSS in Rails 4

In Rails 4, the JS or CSS files, should I putting them in vendor > assets or in app > assets?
There are 3 asset locations in Rails
/app/assets/{images,javascripts,stylesheets} for the application-specific assets.
/lib/assets/{images,javascripts,stylesheets} for library assets. It's not very clear the boundary between this folder and the others, there is a lot of overlap. However, you normally place here assets that are shared across multiple apps under your control or libraries that don't normally tie specifically to the application.
/vendor/assets/{images,javascripts,stylesheets} for vendored assets. You should place here assets downloaded from packages where you have no control and that are not intended to be manually edited. This is the case, for instance, of bootstrap, jquery or other frameworks, as well as javascript plugins.
There is one important difference to keep in mind. Assets in /app are reloaded on every request. The other folders are not autoreloaded, thus if you make changes you will need to restart the server.
Your CSS goes in app/assets. CSS from 3rd party vendors goes in vendor/assets.

Rails Twitter-Boostrap : Load many assets files (javascript and css)

I just started to use twitter-boostrap gem for my simple app.
When I check it loads some many javascript file which I believed it does not use in a particular page. just like show in the following image
http://i.imgur.com/Aluth.png
So the question, is it possible to manage which js file should be loaded in a page?
Thanks.

Assets pipeline, css works but not js

My site has problems with finding javascripts and some of the images. It cannot display the images that is located within folders in the assets/images/ and none of the js and jquery.
The css works fine. But the weird thing is that when I moved the images down one folder to the assets folder, they still didn't work. Been trying to find something in assets pipeline guide:
http://guides.rubyonrails.org/asset_pipeline.html
But without a result. Could it be related to some precompiling? I tried some precompliling, but no changes.
I'm open for all suggestions! Thank you.
Edit: After som more research I found that it has generated most of the files in a folder in public/assets, and it grabs all files from there. I don't know why it generates them to that folder nor how to direct it to grab them from app/assets/javascripts.
See http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails to find out how to change the asset path.

Resources