通过Rails中的视图加载.coffee文件

我的控制器如下:

class CommentLoaderController < ApplicationController respond_to :js def show puts 'here' @client_id = params[:id] respond_with @client_id end end 

它加载一个.js文件,里面有一些.erb标记。 我想加载一个CoffeeScript文件,即时编译成JS。 这可能与Rails 3有关吗?

我认为今天我的一位同事写的这篇博文可能有所帮助

http://www.storm-consultancy.com/blog/development/random-bits/todays-gotcha-when-coffeescript-templates-in-rails-work-in-development-but-not-production/

事实certificate,Rails默认情况下不会编译CoffeeScript模板,但你可以安装Coffeebean gem并且神奇地工作。