Ruby on Rails:在Home#index中,application.js文件,Sprockets :: FileNotFound出错

时间:2011-12-04 04:18:26

标签: ruby-on-rails ruby ruby-on-rails-3.1 asset-pipeline sprockets

http://0.0.0.0:3000/

Sprockets::FileNotFound in Home#index

Showing /home/user1/rorblog/app/views/layouts/application.html.erb where line #6 raised:

couldn't find file 'jquery'
  (in /home/user1/rorblog/app/assets/javascripts/application.js:7)

Extracted source (around line #6):

3: <head>
4:   <title>Rorblog</title>
5:   <%= stylesheet_link_tag    "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>

但看起来所有文件都在那里。

application.html.erb =&gt;

<!DOCTYPE html>
<html>
<head>
  <title>Rorblog</title>
  <%= stylesheet_link_tag    "application" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>
<div id="container">

    <div id="header">

        <ul class="hmenu">
            <li>
                <%= link_to('Home', home_index_path ) %>
            </li>
            <% if user_signed_in? %>
              <li>
                <%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
              </li>

              <li>
                <%= link_to('Edit registration', edit_user_registration_path) %>
              </li>

            <% else %>
              <li>
                <%= link_to('Login', new_user_session_path)  %>
              </li>
            <% end %>
        </ul>
        <p class="notice"><%= notice %></p>
        <p class="alert"><%= alert %></p>       
    </div>

    <div id="content">
        <div id="loadwhat">
            <%= yield %>
        </div>
    </div>

    <div id="footer">
        <%= "user1@copyright.com" %>
    </div>
</div>

</body>
</html>

Gemfile =&gt;

source 'http://rubygems.org'

#gem 'rails', '3.1.1'
gem 'rails'

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

gem 'pg'
gem 'devise'
#gem 'rack', '1.3.3'
gem 'will_paginate'

gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
#group :assets do
#  gem 'sass-rails',   '~> 3.1.4'
#  gem 'coffee-rails', '~> 3.1.1'
#  gem 'uglifier', '>= 1.0.3'
#end

#gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

1 个答案:

答案 0 :(得分:6)

在gemfile中取消注释这一行:

#gem 'jquery-rails'