'require_tree .' does not seem to be including the available *.js files as expected. Why?

Hi, all,

Happy new year :slight_smile:

Referring to The Asset Pipeline — Ruby on Rails Guides, it
seems that ‘require_tree .’ in myapp/app/assets/javascripts/
application.js will include all *.js files in the myapp/app/assets/
javascripts/.

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 -----------------------

My App --------------- 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 broken? Thank you :) Gordon

I had also clicked on ‘application.js’ in the line, ‘’ 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] “/javascripts/application.js”<’

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

Action Controller: Exception caught 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; }

Routing Error

No route matches [GET] "/javascripts/
application.js"

---------- 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?

I looked at ‘Upgrading from Old Versions of Rails’ in
The Asset Pipeline — Ruby on Rails Guides 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 :slight_smile:

I created a new rails app in my /tmp directory.

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

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’
end
------ 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 ‘http://rubygems.org

gem ‘rails’, ‘3.1.0’

gem ‘devise’
gem ‘factory_girl_rails’ #, “~> 1.2”
gem ‘paperclip’

Bundle edge Rails instead:

gem ‘rails’, :git => ‘git://github.com/rails/rails.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’
end

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”
end

------ 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 :frowning:

Any ideas?