Loading .coffee files via a view in Rails

左心房为你撑大大i 提交于 2019-12-11 01:55:22

问题


My controller is as follows:

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

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?


回答1:


I think this blog post that one of my colleagues wrote today might help

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

It turns out that Rails won’t compile CoffeeScript templates by default, but you can install the Coffeebean gem and it magically works.



来源:https://stackoverflow.com/questions/8824526/loading-coffee-files-via-a-view-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!