0

如果在资产管道中指定,rails 3.1 会下载 jquery 和 jquery ui 文件吗?我安装了 gems 并且我的 application.js 如下我需要手动将 jquery 复制到管道中吗?

宝石文件:

source 'http://rubygems.org'

gem 'rails', '3.1.0'

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

gem 'sqlite3'


# 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'
  gem 'jquery-rails'
  gem 'jquery-ui-rails'
end

#gem 'jquery-rails'

# 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

布局:

<!DOCTYPE html>
<html>
<head>
  <title>Depot31</title>
  <%= stylesheet_link_tag    "application" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>

应用程序.js

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .
4

1 回答 1

2

如果您在 Gemfile 中添加以下行,资产管道会处理此问题:

gem "jquery-rails"
gem 'jquery-ui-rails'

检查jquery-railsjquery-ui-rails了解更多信息如何设置这个 gem

于 2012-08-11T22:15:38.823 回答