2012-01-08 90 views
9

使用Ruby 1.9.3p0,Rails 3.1.2使用Apache和Passenger正在生产。当我尝试做一个远程功能,它抛出我这个错误:Rails 3咖啡处理程序丢失

ActionView::MissingTemplate (Missing template video/loadVideo, application/loadVideo with 
{:handlers=>[:erb, :builder], :formats=>[:js, "application/ecmascript", "application/x- 
ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, 
:multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}. Searched in 

正如你所看到的,有没有处理程序:咖啡,这就是为什么不处理文件视频/ loadVideo的原因.js.coffee;我运行命令rake资产:预编译但没有任何变化。

的Gemfile中 源 'http://rubygems.org'

gem 'rails', '3.1.2' 

# Bundle edge Rails instead: 
# gem 'rails',  :git => 'git://github.com/rails/rails.git' 

gem 'will_paginate', '~> 3.0' 
gem "bcrypt-ruby", :require => "bcrypt" 
gem 'mysql' 

#Problems in Debian, the error was: 
#Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs #for a list of available runtimes. (ExecJS::RuntimeUnavailable) 
#Solution: http://stackoverflow.com/questions/6282307/rails-3-1-execjs-and-could-not-find-a-javascript-runtime 
gem 'execjs' 
gem 'therubyracer' 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.1.5.rc.2' 
    gem 'coffee-rails', '~> 3.1.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

# To use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

# Use unicorn as the web server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'ruby-debug19', :require => 'ruby-debug' 

group :test do 
    # Pretty printed test output 
    gem 'turn', '0.8.2', :require => false 
end 
+0

里面的咖啡栏宝石并不意味着它提供了一个咖啡处理程序。 – 2012-01-09 01:24:43

+0

请不要使用骆驼案件模板。 Rails约定是使用下划线。 'loadVideo'模板应该是'load_video'。 – 2012-01-09 14:50:35

回答

13

更改您的Gemfile(移动咖啡轨资产组之外宝石)或改变application.rb中设置 - 例如

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    # Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    Bundler.require(:default, :assets, Rails.env) 
end 

在开发环境应用程序默认加载所有宝石从:default, :development, :test, :assets组。咖啡处理程序来自coffee-rails宝石,所以你必须加载它。

+2

我碰到同样的事情,一旦我将咖啡宝石移出资产命名空间,它就起作用了。我想大多数人只会在资产中使用咖啡脚本而不是在视图中......奇怪的是,当Gem仅在资产块中指定时,它在开发模式下工作。 – hoyhoy 2012-05-04 23:08:14