我想在我的Rails 3.1的项目,以测试脚本的咖啡,但它并没有得到执行,或在application.js中rails 3.1,为什么我的咖啡脚本不工作?
我有一个控制器Page
如JavaScript生成的,这里是pages.js.coffee :
test = (input) ->
alert input
test 'hello'
但警报永远不会在http://127.0.0.1:3000/pages, 实际上执行的是application.js中只是空!
这里是Gemfile中的情况下,它会帮助:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'devise', '1.4.8'
gem 'will_paginate', '~> 3.0.2'
#gem 'nested_form', :git => 'git://github.com/fxposter/nested_form.git'
gem "simple_form"
gem 'kaminari'
gem 'foreigner'
gem "cocoon"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem "jquery-rails"
gem 'coffee-script'
gem 'haml'
# 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', :require => false
end
编辑
我也加入了这些宝石和安装的话,但是,咖啡脚本不执行
感谢您的好主意!我创建了一个新项目,并在我的application.js中注意到了不同点,即“// = require_tree”。简直是失踪! – simo
^^这对我来说也是如此。在转换为3.1之后,忘记将这些要求添加到application.js的顶部 –