Hi, all,

Happy new year :)

Referring to http://guides.rubyonrails.org/asset_pipeline.html, 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 -----------------------

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

<script src="/javascripts/jquery.js" type="text/javascript"></
script>
<script src="/javascripts/application.js" type="text/javascript"></
script>
<script src="/javascripts/jquery.min.js" type="text/javascript"></
script>
<script src="/javascripts/jquery_ujs.js" type="text/javascript"></
script>
<!--, "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/
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" />
</head>
<body>


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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • K.M. at Jan 1, 2012 at 5:54 am
    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">
    <head>
    <meta charset="utf-8" />
    <title>Action Controller: Exception caught</title>
    <style>
    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; }
    </style>
    </head>
    <body>

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



    </body>
    </html>

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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • K.M. at Jan 1, 2012 at 6:03 am
    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 :(

    Any ideas?

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • K.M. at Jan 1, 2012 at 6:32 am
    I looked at 'Upgrading from Old Versions of Rails' in
    http://edgeguides.rubyonrails.org/asset_pipeline.html 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 :)

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 1, '12 at 5:43a
activeJan 1, '12 at 6:32a
posts4
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

K.M.: 4 posts

People

Translate

site design / logo © 2021 Grokbase