0

I have two Layouts and each layout have different CSS and Js files. while i use

<%= javascript_include_tag 'application' %>

then, it brings all .js files.

Is anything available like following way:

<%= javascript_include_tag 'folder/script1.js' %>
<%= javascript_include_tag 'folder/script2.js' %>
<%= javascript_include_tag 'folder/script3.js' %> ...

Is there a way to only include all scripts in an specific folder?

Thanks.

1 Answer 1

5

Create a new file application_foo.js with the following content;

//= require_directory folder

Add the following line in your second layout:

<%= javascript_include_tag 'application_foo' %>

This will include all the javascript files of folder directory.

Look at Asset Pipeline Guide for more info.

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.