此处也发布了:https://gist.github.com/1100596。 (这个问题不仅仅与CoffeeBeans宝石有关,我不认为。)
# Controller
class RestaurantsController < ApplicationController
def show
@restaurant = Restaurant.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.js # show.js.coffee
end
end
end
# restaurants/show.html.erb
<%= link_to "Breakfast", @restaurant, :remote => true, :id => "breakfast_filter" %>
# restaurants/show.js.coffee
alert("here we are");
为什么show.js.coffee文件永远不会到达?事实上,即使它是show.js.erb,也不会达到......
重点是,我可以用AJAX重新加载show.html.erb页面的一部分。
背景:我正在使用Rails 3.1rc4,我的Gemfile如下:
source 'http://rubygems.org'
# Using ruby 1.9.2p180
gem 'rails', '3.1.0.rc4' # :git => 'git://github.com/rails/rails.git', :branch => '3-1-stable'
gem 'sprockets', '2.0.0.beta.10' # :git => 'git://github.com/sstephenson/sprockets.git'
#gem 'mysql2' # No longer MySQL
gem 'pg', '0.11.0' # For PostgreSQL db
gem 'authlogic', '3.0.3' # smart user authentication
gem 'cancan', '1.6.5' # manage abilities across types of users
gem 'dynamic_form', '1.1.4' # easy error messages for forms
# Asset template engines
gem 'sass-rails', '~> 3.1.0.rc'
gem 'coffee-script', '~> 2.2.0'
gem 'uglifier', '~> 1.0.0' # compresses JS code for production
# We use jQuery, the default
gem 'jquery-rails', '>= 1.0.12'
# Temporary - 3.1 SHOULD require >=0.9.2, but there are still bugs
gem 'rake', '0.8.7'
# This makes AJAX and CoffeeScript play nicely together
gem 'coffeebeans'
group :production do
gem 'therubyracer', '~> 0.9.3.beta1'
end
gem 'factory_girl_rails' # seeds.rb needs this
#gem 'forgery'
group :test, :development do
# helpers
gem 'database_cleaner'
# core testing frameworks
gem 'rspec-rails', '>= 2.6.1'
gem 'cucumber-rails', '>= 1.0.0'
gem 'capybara', '>= 1.0.0'
# Pretty printed test output
gem 'turn', :require => false
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
帮助表示赞赏。