Heroku 需要配置什么来处理基于 CoffeeScript 的模板? [英] What needs to be configured for Heroku to handle templates based on CoffeeScript?

查看:22
本文介绍了Heroku 需要配置什么来处理基于 CoffeeScript 的模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处理 AJAX 请求的创建操作.在我的开发机器上,一个名为 create.js.coffee 的模板被成功处理以生成一个 javascript 响应.但是,当我部署到 Heroku 时,应用程序抱怨它找不到模板.

I have a create action that handles an AJAX request. On my development machine, a template named create.js.coffee is successfully processed to generate a javascript response. However, when I deploy to Heroku, the application complains that it can't find the template.

ActionView::MissingTemplate (Missing template /expenses/create with {:handlers=>[:erb, :builder], :formats=>[:js, :html], :locale=>[:en, :en]}. Searched in:
* "/app/app/views"
* "/app"
* "/"
):

很明显,咖啡处理程序不是用来预处理 *.js.coffee 模板的.

It's clear that the coffee handler is not there to preprocess *.js.coffee template.

谁能建议我如何配置 Heroku 来识别和处理这些模板?

Can any one suggest how I can configure Heroku to recognize and process these templates?

注意:Heroku 正在成功地预处理资产管道中存在的我的 CoffeeScript 文件.

Note: Heroku is successfully preprocessing my CoffeeScript files that are present in the asset pipeline.

推荐答案

我参加聚会有点晚了,但这是我的解决方案,发布在 Gi​​thub.

I'm a bit late to the party, but here is my solution, as posted on Github.

我刚遇到一个问题,我的 create.js.coffee 文件在 development 中工作,但在 production 中停止工作(在 Heroku).日志显示 Rails 甚至没有寻找咖啡处理程序:

I just ran into a problem where my create.js.coffee file was working in development but stopped working in production (on Heroku). The logs show that Rails isn't even looking for a coffee handler:

2011-10-14T08:26:29+00:00 app[web.1]: ActionView::MissingTemplate (Missing template page_blocks/create, application/create with {:handlers=>[:erb, :builder, :haml], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:nl, :nl]}. Searched in:
2011-10-14T08:26:29+00:00 app[web.1]:   * "/app/app/views"
2011-10-14T08:26:29+00:00 app[web.1]: ):

这是我的 Gemfile 的(重要)部分:

This is the (important) part of my Gemfile:

group :assets do
  gem "sass-rails", "~> 3.1.0"
  gem "coffee-rails", "~> 3.1.0"
  gem "uglifier"
  gem "compass", "~> 0.12.alpha"
end

# asset templates
gem "jquery-rails"
gem "haml"

只有在我将 coffee-rails 移出 :assets 组之后,事情才开始起作用.也许在自述文件中以某种方式明确这一点是个好主意,甚至可能在发布 Rails 时将 coffee-rails 插件放在 assets 组之外.

Only after I moved coffee-rails outside of the :assets group, things started working. Perhaps it would be a good idea to somehow make this clear in the readme, and perhaps even ship Rails with the coffee-rails plugin being placed outside the assets group.

这篇关于Heroku 需要配置什么来处理基于 CoffeeScript 的模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆