2012-03-26 102 views
0

不知何故無法獲得JavaScript運行:heroku /雪松JavaScript不工作

我試圖使用rails 3.2.2,Heroku,雪松堆棧。該應用程序在本地運行良好,似乎正在部署到Heroku,但JavaScript拒絕運行。這個線程似乎涵蓋了類似的問題,但沒有在最後一個良好的解決方案,因此想我會嘗試再次 javascript not running on heroku with rails 3.1

,如下圖所示,我我的JavaScript精簡到最低限度。雖然我沒有顯示heroku部署日誌,但它看起來很好(預編譯通過等)。我留下的最小JavaScript做了兩件事:在表單上按下輸入時發出警報(想要測試所有javascript而不僅僅是jQuery-UI不工作),另外兩個函數支持jQuery-UI

資產管道編譯過程看起來很好,即我的js/css在瀏覽器html鏈接中可用,我已經查看了螢火蟲,當我嘗試觸發javascript時,似乎沒有發生任何事情(雖然我不是專家的螢火蟲用戶。 ..)

有什麼想法嗎?

謝謝!

寶石的文件: 源 'https://rubygems.org'

gem 'rails', '3.2.2' 

gem "pg" 

group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 
gem 'devise' 

gem 'gravatar_image_tag', '1.0.0.pre2' 
gem 'will_paginate' 
gem 'omniauth' 
gem 'omniauth-facebook' 
gem 'fb_graph' 
gem 'carrierwave' 
gem 'fog' 
gem 'mini_magick' 
gem 'aws-s3', :require => 'aws/s3' 
gem "nested_form", :git => 'https://github.com/ryanb/nested_form.git' 

group :development do 
    gem 'rspec-rails', '2.6.1' 
    gem 'annotate', '2.4.0' 
    gem 'faker', '0.3.1' 
end 

group :test do 
    gem 'rspec-rails', '2.6.1' 
    gem 'webrat', '0.7.1' 
    gem 'spork', '0.9.0.rc8' 
    gem 'factory_girl_rails', '1.0' 
end 

group :production do 
end 

application.css

/* 
*= require_self 
*= require_tree . 
*= require_tree ../../../vendor/assets/stylesheets 
*/ 

的application.js

// Place your application-specific JavaScript functions and classes here 
//= require jquery 
//= require jquery_ujs 
//= require jquery-ui 
//= require_tree . 

var $ = jQuery.noConflict(); 

//function to prevent submission of form on enter 
$(function() { 
    $("input").not($(":button")).keypress(function (evt) { 
    if (evt.keyCode == 13) { 
     alert("enter pressed"); 
     return false; 
    } 
    }); 
}); 

// default tab option e.g. to show menu 
$(function() { 
    $("#tabs").tabs() 
}); 

// datepicker in add visit form 
$(function() { 
    $("#visit_visit_date").datepicker({ dateFormat: 'yy-mm-dd' }); 
}); 

application.html.erb:

<%= stylesheet_link_tag "application" %> 
<%= javascript_include_tag "application" %> 

Heroku的日誌

2012-03-26T07:44:37+00:00 app[web.1]: [2012-03-26 07:44:37] INFO WEBrick::HTTPServer#start: pid=1 port=34422 
2012-03-26T07:44:39+00:00 heroku[web.1]: State changed from starting to up 
2012-03-26T07:44:46+00:00 app[web.1]: => Rails 3.2.2 application starting in production on http://0.0.0.0:34422 
2012-03-26T07:44:46+00:00 app[web.1]: => Booting WEBrick 
2012-03-26T07:44:46+00:00 app[web.1]: => Call with -d to detach 
2012-03-26T07:44:46+00:00 app[web.1]: => Ctrl-C to shutdown server 
2012-03-26T07:44:46+00:00 app[web.1]: 
2012-03-26T07:44:46+00:00 app[web.1]: 
2012-03-26T07:44:46+00:00 app[web.1]: Started GET "/" for 86.145.200.112 at 2012-03-26 07:44:46 +0000 
2012-03-26T07:44:46+00:00 app[web.1]: Processing by AuthenticationsController#index as HTML 
2012-03-26T07:44:47+00:00 app[web.1]: Rendered layouts/_main_sidebar.html.erb (3.9ms) 
2012-03-26T07:44:47+00:00 app[web.1]: Rendered authentications/index.html.erb within layouts/application (249.3ms) 
2012-03-26T07:44:47+00:00 app[web.1]: Rendered layouts/_css_and_js.html.erb (0.9ms) 
2012-03-26T07:44:47+00:00 app[web.1]: Rendered layouts/_header.html.erb (12.1ms) 
2012-03-26T07:44:47+00:00 app[web.1]: Rendered shared/_flash_box.html.erb (5.5ms) 
2012-03-26T07:44:47+00:00 app[web.1]: Completed 200 OK in 866ms (Views: 443.0ms | ActiveRecord: 66.1ms) 
2012-03-26T07:44:47+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.9ms) 
2012-03-26T07:44:47+00:00 app[web.1]: cache: [GET /] miss 
2012-03-26T07:44:47+00:00 heroku[router]: GET rlog.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=6822ms status=200 bytes=4194 
2012-03-26T07:44:47+00:00 app[web.1]: cache: [GET /assets/application-5090c5eabae5ecffdf7ce4cba7884c06.css] miss 
2012-03-26T07:44:47+00:00 heroku[router]: GET rlog.herokuapp.com/assets/application-5090c5eabae5ecffdf7ce4cba7884c06.css dyno=web.1 queue=0 wait=0ms service=9ms status=200 bytes=29028 
2012-03-26T07:44:48+00:00 app[web.1]: cache: [GET /assets/application-eed65c1aadddd24237c794c315626b08.js] miss 
2012-03-26T07:44:48+00:00 app[web.1]: cache: [GET /assets/facebook_32-45445447cea198ebc8cc24ce1a99cddc.png] miss 
2012-03-26T07:44:48+00:00 heroku[router]: GET rlog.herokuapp.com/assets/facebook_32-45445447cea198ebc8cc24ce1a99cddc.png dyno=web.1 queue=0 wait=0ms service=6ms status=200 bytes=1681 
2012-03-26T07:44:48+00:00 app[web.1]: cache: [GET /assets/facebook_64-654f0f2c1ba7e19e730d497947534230.png] miss 
2012-03-26T07:44:48+00:00 heroku[router]: GET rlog.herokuapp.com/assets/facebook_64-654f0f2c1ba7e19e730d497947534230.png dyno=web.1 queue=0 wait=0ms service=68ms status=200 bytes=3448 
2012-03-26T07:44:48+00:00 heroku[router]: GET rlog.herokuapp.com/assets/application-eed65c1aadddd24237c794c315626b08.js dyno=web.1 queue=0 wait=0ms service=97ms status=200 bytes=455343 
2012-03-26T07:44:50+00:00 app[web.1]: cache: [GET /assets/images/img02.jpg] miss 
2012-03-26T07:44:50+00:00 heroku[router]: GET rlog.herokuapp.com/assets/images/img03.jpg dyno=web.1 queue=0 wait=0ms service=42ms status=200 bytes=824 
2012-03-26T07:44:50+00:00 app[web.1]: cache: [GET /assets/images/img03.jpg] miss 
2012-03-26T07:44:50+00:00 heroku[router]: GET rlog.herokuapp.com/assets/images/img02.jpg dyno=web.1 queue=0 wait=0ms service=56ms status=200 bytes=17861 
2012-03-26T07:45:30+00:00 app[web.1]: 
2012-03-26T07:45:30+00:00 app[web.1]: 
2012-03-26T07:45:30+00:00 app[web.1]: Started GET "/stores" for 86.145.200.112 at 2012-03-26 07:45:30 +0000 
2012-03-26T07:45:30+00:00 app[web.1]: Processing by StoresController#index as HTML 
2012-03-26T07:45:30+00:00 app[web.1]: Rendered layouts/_main_sidebar.html.erb (1.9ms) 
2012-03-26T07:45:30+00:00 heroku[router]: GET rlog.herokuapp.com/stores dyno=web.1 queue=0 wait=0ms service=117ms status=200 bytes=3954 
2012-03-26T07:45:30+00:00 app[web.1]: Rendered stores/index.html.erb within layouts/application (70.8ms) 
2012-03-26T07:45:30+00:00 app[web.1]: Rendered layouts/_css_and_js.html.erb (1.6ms) 
2012-03-26T07:45:30+00:00 app[web.1]: Rendered shared/_flash_box.html.erb (0.1ms) 
2012-03-26T07:45:30+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.3ms) 
2012-03-26T07:45:30+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.3ms) 
2012-03-26T07:45:30+00:00 app[web.1]: Completed 200 OK in 108ms (Views: 64.2ms | ActiveRecord: 22.5ms) 
2012-03-26T07:45:30+00:00 app[web.1]: cache: [GET /stores] miss 
2012-03-26T07:45:30+00:00 app[web.1]: cache: [GET /assets/application-eed65c1aadddd24237c794c315626b08.js] miss 
2012-03-26T07:45:30+00:00 app[web.1]: cache: [GET /assets/application-509 
0c5eabae5ecffdf7ce4cba7884c06.css] miss 
2012-03-26T07:45:30+00:00 heroku[router]: GET rlog.herokuapp.com/assets/application-5090c5eabae5ecffdf7ce4cba7884c06.css dyno=web.1 queue=0 wait=0ms service=14ms status=304 bytes=0 
2012-03-26T07:45:30+00:00 heroku[router]: GET rlog.herokuapp.com/assets/application-eed65c1aadddd24237c794c315626b08.js dyno=web.1 queue=0 wait=0ms service=17ms status=304 bytes=0 
2012-03-26T07:45:31+00:00 app[web.1]: cache: [GET /assets/images/img03.jpg] miss 
2012-03-26T07:45:31+00:00 heroku[router]: GET rlog.herokuapp.com/assets/images/img03.jpg dyno=web.1 queue=0 wait=0ms service=19ms status=304 bytes=0 
2012-03-26T07:45:31+00:00 app[web.1]: cache: [GET /assets/images/img02.jpg] miss 
2012-03-26T07:45:31+00:00 heroku[router]: GET rlog.herokuapp.com/assets/images/img02.jpg dyno=web.1 queue=0 wait=0ms service=24ms status=304 bytes=0 
2012-03-26T07:45:32+00:00 app[web.1]: 
2012-03-26T07:45:32+00:00 app[web.1]: 
2012-03-26T07:45:32+00:00 app[web.1]: Parameters: {"id"=>"2"} 
2012-03-26T07:45:32+00:00 app[web.1]: Started GET "/show_rast?id=2" for 86.145.200.112 at 2012-03-26 07:45:32 +0000 
2012-03-26T07:45:32+00:00 app[web.1]: Processing by StoresController#show_rast as HTML 
2012-03-26T07:45:33+00:00 app[web.1]: Rendered layouts/_main_sidebar.html.erb (0.9ms) 
2012-03-26T07:45:33+00:00 app[web.1]: Rendered stores/show_rast.html.erb within layouts/application (103.6ms) 
2012-03-26T07:45:33+00:00 app[web.1]: Re 
ndered layouts/_css_and_js.html.erb (0.7ms) 
2012-03-26T07:45:33+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.2ms) 
2012-03-26T07:45:33+00:00 app[web.1]: Rendered shared/_flash_box.html.erb (0.0ms) 
2012-03-26T07:45:33+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.3ms) 
2012-03-26T07:45:33+00:00 app[web.1]: Completed 200 OK in 459ms (Views: 108.9ms | ActiveRecord: 177.3ms) 
2012-03-26T07:45:33+00:00 app[web.1]: cache: [GET /show_rast?id=2] miss 
2012-03-26T07:45:33+00:00 heroku[router]: GET rlog.herokuapp.com/show_rast dyno=web.1 queue=0 wait=0ms service=474ms status=200 bytes=37071 
2012-03-26T07:45:38+00:00 app[web.1]: 
2012-03-26T07:45:38+00:00 app[web.1]: 
2012-03-26T07:45:38+00:00 app[web.1]: Started GET "/stores" for 86.145.200.112 at 2012-03-26 07:45:38 +0000 
2012-03-26T07:45:38+00:00 app[web.1]: Processing by StoresController#index as HTML 
2012-03-26T07:45:38+00:00 app[web.1]: Rendered layouts/_main_sidebar.html.erb (0.7ms) 
2012-03-26T07:45:38+00:00 app[web.1]: Rendered shared/_flash_box.html.erb (0.0ms) 
2012-03-26T07:45:38+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.3ms) 
2012-03-26T07:45:38+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.7ms) 
2012-03-26T07:45:38+00:00 app[web.1]: Completed 200 OK in 20ms (Views: 12.0ms | ActiveRecord: 5.3ms) 
2012-03-26T07:45:38+00:00 app[web.1]: cache: [GET /stores] miss 
2012-03-26T07:45:38+00:00 app[web.1]: Rendered stores/index.html.erb within layouts/application (10.7ms) 
2012-03-26T07:45:38+00:00 app[web.1]: Rendered layouts/_css_and_js.html.erb (0.7ms) 
2012-03-26T07:45:38+00:00 heroku[router]: GET rlog.herokuapp.com/stores dyno=web.1 queue=0 wait=0ms service=31ms status=304 bytes=0 
2012-03-26T07:45:39+00:00 app[web.1]: 
2012-03-26T07:45:39+00:00 app[web.1]: 
2012-03-26T07:45:39+00:00 app[web.1]: Started GET "/visits/new?id=2" for 86.145.200.112 at 2012-03-26 07:45:39 +0000 
2012-03-26T07:45:39+00:00 app[web.1]: Processing by VisitsController#new as HTML 
2012-03-26T07:45:39+00:00 app[web.1]: Parameters: {"id"=>"2"} 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_cart_item.html.erb (1.9ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_cart.html.erb (2.7ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_cart_sidebar.html.erb (3.7ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered shared/_error_messages.html.erb (0.4ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_fields.html.erb (1.2ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_rast_tabs.html.erb (133.6ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_dish_review_fields.html.erb (6.6ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/_picture_fields.html.erb (0.8ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered visits/new.html.erb within layouts/application (179.6ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered layouts/_css_and_js.html.erb (0.7ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered layouts/_header.html.erb (1.3ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered shared/_flash_box.html.erb (0.0ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.3ms) 
2012-03-26T07:45:39+00:00 app[web.1]: Completed 200 OK in 251ms (Views: 178.5ms | ActiveRecord: 19.6ms) 
2012-03-26T07:45:39+00:00 app[web.1]: cache: [GET /visits/new?id=2] miss 
2012-03-26T07:45:39+00:00 heroku[router]: GET rlog.herokuapp.com/visits/new dyno=web.1 queue=0 wait=0ms service=284ms status=200 bytes=54444 
+0

您能否將我們鏈接到該網站? – Dogbert 2012-03-26 09:00:19

+0

我不希望因爲網站/代碼將進入商業項目。有沒有具體的調試,你可以告訴我?如果不是,我也可以創建另一個項目,並提供精簡功能進行測試,但會花費一些時間?謝謝! – 2012-03-26 10:06:54

+0

因此,如果您直接輸入網址,js文件的加載效果會好嗎?它確定包含在頁面中?還是不行?如果是這樣,我想我需要看看現場測試網站進行調試。 – Dogbert 2012-03-26 10:13:55

回答

0

我想通了,我的問題。我在app/assets/javascripts /文件夾中有一些其他文件(script.aculo.us文件(controls.js,dragdrop.js,effects.js)和prototype.js(來自以前的程序迭代的剩餘部分)那些通過// = require_tree調用與application.js一起被包含在資產管道中sciprt.aculo.us文件似乎已經搞亂了東西

我現在設法讓我的程序我假設我不再需要script.aculo.us(與jquery-ui類似的東西),也不prototype.js(現在使用jquery),我錯了嗎?

Dogbert thx爲您提供幫助。

相關問題