0

I have a template that I'm trying to include on my Rails Aplication. This template has it's own structure that I don't want to mess with. Lets call this template "material".

I've put all the files under my vendor/assets folder, so that I have this structure:

railsApp/vendor/assets/material/material

Inside this last "material" folder, I have the folders with my JS and CSS. This way I've created a file "material.js" that does the includes:

//= require material/js/jquery-2.1.1
//= require material/js/functions
//= require material/js/bootstrap

so that I can call the js that I want.

Here is my problem: How can I call this material.js from my application.html.erb ?

<%= javascript_include_tag '/vendor/assets/material/material/material', 'data-turbolinks-track' => true %> 

Does not work...

Thanks in advance.

1 Answer 1

4

I would create a new js file, let's say material.js. In app/assets/javascripts/material.js:

//= require material/material

Then in your config/application.rb, you need to add:

config.assets.paths << Rails.root.join('vendor', 'assets', 'material').

You would also need to add material.js to the pre-compile list. In config/initializers/assets.rb:

Rails.application.config.assets.precompile += %w( material.js ).

And then in your view, you can reference material:

javascript_include_tag 'material'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.