Forum: Ruby on Rails 'require_tree .' does not seem to be including the available *.js files as expected. Why?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
K.M. (Guest)
on 2012-01-01 06:44
(Received via mailing list)
Hi, all,

 Happy new year :)

Referring to, it
seems that 'require_tree .' in myapp/app/assets/javascripts/
application.js will include all *.js files in the myapp/app/assets/

 I have a few other *.js files in this directory : parts.js, makes.js
and categories.js.

Here's an extract from the html file I am viewing:

--------------- Extract start -----------------------

<!DOCTYPE html>
  <title>My App</title>

  <script src="/javascripts/jquery.js" type="text/javascript"></
<script src="/javascripts/application.js" type="text/javascript"></
<script src="/javascripts/jquery.min.js" type="text/javascript"></
<script src="/javascripts/jquery_ujs.js" type="text/javascript"></
<!--,  "
jquery.min.js" %>
- "jquery.js", "application.js", "jquery.min.js" , "jquery_ujs.js" -->

<!-- :defaults, "jquery.min.js" -->
  <meta content="authenticity_token" name="csrf-param" />
<meta content="jfiFh0CGHgl5F6mX/dORtk1y6IMfnbCavwgx4bVYXbA="
name="csrf-token" />

--------------- Extract end  -----------------------

My 'app/assets/javascripts/application.js' file is:

--------------- Extract start -----------------------
//= require jquery
//= require jquery_ujs
//= require_tree .

--------------- Extract end  -----------------------

My question: I am using rails 3.1.0 and when I open up a page in the
webbrowser and view source,  I am not seeing the 3 js files above
being included. Why are the 3 files not included? Is require_tree

Thank you :)

K.M. (Guest)
on 2012-01-01 06:56
(Received via mailing list)
I had also clicked on 'application.js' in the line, '<script src="/
javascripts/application.js" type="text/javascript"></script>' in the
html file.

It looks like the files in app/assets cannot be accessed.

Here's what the source looks like. Observe the message, 'No route
matches [GET] &quot;/javascripts/application.js&quot;<'

---------- Extract of source starts -----------------------

<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8" />
  <title>Action Controller: Exception caught</title>
    body { background-color: #fff; color: #333; }

    body, p, ol, ul, td {
      font-family: helvetica, verdana, arial, sans-serif;
      font-size:   13px;
      line-height: 18px;

    pre {
      background-color: #eee;
      padding: 10px;
      font-size: 11px;

    a { color: #000; }
    a:visited { color: #666; }
    a:hover { color: #fff; background-color:#000; }

<h1>Routing Error</h1>
<p><pre>No route matches [GET] &quot;/javascripts/


---------- Extract of source ends  -----------------------

WIth the introduction of asset pipeline, should new routes be added to
enable files in the app/assets directory to be accessed?
K.M. (Guest)
on 2012-01-01 07:04
(Received via mailing list)
I created a new rails app in my /tmp directory.

I noticed that the Gemfile had something new relating to the asset

The app I am working on was created with rails 3.0.x and hence, I made
a change to my Gemfile to use rails 3.1.0 and ran "bundle install" to
get rails 3.1.0 in.

------ This is what I saw in the Gemfile of a new 3.1.0 app I created
(start) --------
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
------ This is what I saw in the Gemfile of a new 3.1.0 app I created
(end) --------

Seeing that and the fact that I use jquery and not coffee script or
sass (for css),
I altered my own Gemfile of the application which I am encountering a
problem with. See below.

------ This is what my current gemfile looks like (start) --------

source ''

gem 'rails', '3.1.0'

gem 'devise'
gem 'factory_girl_rails' #, "~> 1.2"
gem 'paperclip'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://'

gem 'sqlite3'
gem 'jquery-rails', '>= 1.0.12'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
#  gem 'sass-rails', "  ~> 3.1.0"
#  gem 'coffee-rails', "~> 3.1.0"
  gem 'jquery-rails', '>= 1.0.12'
  gem 'uglifier'

# clean up test db after each spec test run
gem "database_cleaner", "~> 0.6.7"

group :development, :test do
    gem "rspec-rails", ">= 2.0.0"
    gem "webrat", ">= 0.7.2"

------ This is what my current gemfile looks like (end) --------

I restarted my server and yet there's still no luck in accessing the
assets/javascripts/application.js file in my browser :(

Any ideas?
K.M. (Guest)
on 2012-01-01 07:33
(Received via mailing list)
I looked at 'Upgrading from Old Versions of Rails' in and that has now
fixed the problem whereby files in assets/ can now be accessed.

 I followed the changes recommended and they worked.
Nevertheless, I could not see my custom javascript files in the html
when i view its source.

Thank you in advance for any help :)
This topic is locked and can not be replied to.