通过Rails中的视图加载.coffee文件 [英] Loading .coffee files via a view in Rails
本文介绍了通过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吗?
It loads a .js file which has some .erb markup in it. I'd like to load a CoffeeScript file, compiled to JS on the fly. Is this possible with Rails 3?
推荐答案
我认为今天的一个同事写的这篇博文可能会帮助
I think this blog post that one of my colleagues wrote today might help
原来Rails不会编译CoffeeScript模板默认为
,但您可以安装 Coffeebean 宝石,并且神奇地
It turns out that Rails won’t compile CoffeeScript templates by default, but you can install the Coffeebean gem and it magically works.
这篇关于通过Rails中的视图加载.coffee文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文