Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
 
Oh Thanks. I will try and let you know –  suresh.g May 18 at 7:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.