Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 Coffee Handler Missing

Im using Ruby 1.9.3p0, Rails 3.1.2 with Apache and Passenger in Production. When I try to make a remote function, it throws me this error:

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

As you can see, there is no handler for :coffee, that's the reason why is not processing the file video/loadVideo.js.coffee; I run the command rake assets:precompile but nothing changes.

The Gemfile source '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
like image 618
pablomarti Avatar asked Jan 08 '12 23:01

pablomarti


1 Answers

Change your Gemfile (move coffee-rails gem outside the assets group) or change your application.rb settings - for instance

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

In development environment application by default loads all of gems from :default, :development, :test, :assets groups. Coffee handler comes from coffee-rails gem, so you have to load it.

like image 104
Bard Avatar answered Oct 02 '22 05:10

Bard