我想在我的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的頂部 –