2012-09-27 87 views
0

我正在完成关于Rails的教程 - 但是该教程是用Rails 2编写的,而且因为我有Rails 3,我不得不将所有内容都转换。Rails AJAX 500错误

我有一个谷歌地图,当你点击它时,你应该弹出一个新的标记和输入数据的表单。当我点击地图时,标记出现,但没有输入数据的表单。任何帮助将非常感激!

我猜它与ajax有关?当我点击地图上的任何地方尝试输入新数据时,Web控制台给我一个500内部服务器错误。不知道我要去哪里错了!

下面是 '新' 的动作的控制器编码:

def new 
    @incident = Incident.new 

    respond_to do |format| 
    format.html { 
     @incident.latitude=params['latitude'] 
     @incident.longitude=params['longitude'] 
     render :partial=>'new', :locals=>{:incident=>@incident} 
    } 
    format.xml { render :xml => @incident } 
    end 
end 

索引视图:

<h1>Listing incidents</h1> 

<%= render(:partial=>"map", :locals=>{:data=>"/incidents.xml", 
    :full_page=>true, :show_action=>'show', :new_action=>'new'}) %> 

和 '新' 部分:

<h1>New incident</h1> 
<% form_for(incident, :update=>'map_info'), :remote => true do |f| %> 
<p> 
    <%= f.label :mountain %> <%= f.text_field :mountain %> 
</p> 
<%= f.hidden_field :latitude %> 
<%= f.hidden_field :longitude %> 
<p> 
    <%= f.label :when %> <%= f.datetime_select :when %> 
</p> 
<p> 
    <%= f.label :title %> <%= f.text_field :title %> 
</p> 
<p> 
    <%= f.label :description %><br/> 
    <%= f.text_area :description, :rows=>3 %> 
</p> 
<p> 
    <%= f.submit "Create" %> 
</p> 
<% end %> 

这里的堆跟踪(当我加载页面,然后点击地图上的新事件):

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-09-27 14:35:18 
+0100 
Served asset /application.js - 304 Not Modified (173ms) 
[2012-09-27 14:35:18] WARN Could not determine content-length of response body. 
Set content-length of the response or set Response#chunked = true 


Started GET "/assets/prototype.js?body=1" for 127.0.0.1 at 2012-09-27 14:35:18 + 
0100 
Served asset /prototype.js - 304 Not Modified (0ms) 
[2012-09-27 14:35:18] WARN Could not determine content-length of response body. 
Set content-length of the response or set Response#chunked = true 


Started GET "/incidents.xml" for 127.0.0.1 at 2012-09-27 14:35:19 +0100 
Processing by IncidentsController#index as XML 
    ←[1m←[35mIncident Load (1.0ms)←[0m SELECT "incidents".* FROM "incidents" 
    Rendered text template (0.0ms) 
Completed 200 OK in 945ms (Views: 184.0ms | ActiveRecord: 1.0ms) 
[2012-09-27 14:35:20] WARN Could not determine content-length of response body. 
Set content-length of the response or set Response#chunked = true 


Started GET "/incidents/new?latitude=42.50990089326676&longitude=-99.4921875" fo 
r 127.0.0.1 at 2012-09-27 14:35:43 +0100 
Processing by IncidentsController#new as JS 
    Parameters: {"latitude"=>"42.50990089326676", "longitude"=>"-99.4921875"} 
ERROR: compiling _app_views_incidents__new_html_erb___613446974_25808988 RAISED 
c:/Ruby193/incidents/app/views/incidents/_new.html.erb:2: syntax error, unexpect 
ed ',', expecting keyword_end 
'); form_for(incident, :update=>'map_info'), :remote => true do |f| 
              ^
c:/Ruby193/incidents/app/views/incidents/_new.html.erb:23: syntax error, unexpec 
ted keyword_ensure, expecting $end 
Function body:   def _app_views_incidents__new_html_erb___613446974_2580 
8988(local_assigns, output_buffer) 
      _old_virtual_path, @virtual_path = @virtual_path, "incidents/_new";_ 
old_output_buffer = @output_buffer;incident = local_assigns[:incident];new = loc 
al_assigns[:new];;@output_buffer = output_buffer || ActionView::OutputBuffer.new 
;@output_buffer.safe_concat('<h1>New incident</h1> 
'); form_for(incident, :update=>'map_info'), :remote => true do |f| 
@output_buffer.safe_concat(' <p> 
    ');@output_buffer.append= (f.label :mountain);@output_buffer.safe_concat(' 
');@output_buffer.append= (f.text_field :mountain);@output_buffer.safe_concat 
(' 
');@output_buffer.safe_concat(' </p> 
    ');@output_buffer.append= (f.hidden_field :latitude);@output_buffer.safe_con 
cat(' 
');@output_buffer.safe_concat(' ');@output_buffer.append= (f.hidden_field :lon 
gitude);@output_buffer.safe_concat(' 
');@output_buffer.safe_concat(' <p> 
    ');@output_buffer.append= (f.label :when);@output_buffer.safe_concat(' '); 
@output_buffer.append= (f.datetime_select :when);@output_buffer.safe_concat(' 
');@output_buffer.safe_concat(' </p> 
    <p> 
    ');@output_buffer.append= (f.label :title);@output_buffer.safe_concat(' ') 
;@output_buffer.append= (f.text_field :title);@output_buffer.safe_concat(' 
');@output_buffer.safe_concat(' </p> 
    <p> 
    ');@output_buffer.append= (f.label :description);@output_buffer.safe_conca 
t('<br/> 
    ');@output_buffer.append= (f.text_area :description, :rows=>3);@output_buf 
fer.safe_concat(' 
');@output_buffer.safe_concat(' </p> 
    <p> 
    ');@output_buffer.append= (f.submit "Create");@output_buffer.safe_concat(' 

');@output_buffer.safe_concat(' </p> 
'); end 
@output_buffer.to_s 
      ensure 
      @virtual_path, @output_buffer = _old_virtual_path, _old_output_buffe 
r 
      end 

Backtrace: C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_v 
iew/template.rb:297:in `module_eval' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/templat 
e.rb:297:in `compile' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/templat 
e.rb:244:in `block in compile!' 
<internal:prelude>:10:in `synchronize' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/templat 
e.rb:232:in `compile!' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/templat 
e.rb:144:in `block in render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications.rb:125:in `instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/templat 
e.rb:143:in `render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/partial_renderer.rb:265:in `render_partial' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/partial_renderer.rb:238:in `block in render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/abstract_renderer.rb:38:in `block in instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications.rb:123:in `block in instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications/instrumenter.rb:20:in `instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications.rb:123:in `instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/abstract_renderer.rb:38:in `instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/partial_renderer.rb:237:in `render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/renderer.rb:41:in `render_partial' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_view/rendere 
r/renderer.rb:15:in `render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/rendering.rb:110:in `_render_template' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/streaming.rb:225:in `_render_template' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/rendering.rb:103:in `render_to_body' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/renderers.rb:28:in `render_to_body' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/compatibility.rb:50:in `render_to_body' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/rendering.rb:88:in `render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/rendering.rb:16:in `render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/instrumentation.rb:40:in `block (2 levels) in render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
ore_ext/benchmark.rb:5:in `block in ms' 
C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:295:in `realtime' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
ore_ext/benchmark.rb:5:in `ms' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/instrumentation.rb:40:in `block in render' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/instrumentation.rb:83:in `cleanup_view_runtime' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.4.rc1/lib/active_record/rai 
lties/controller_runtime.rb:24:in `cleanup_view_runtime' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/instrumentation.rb:39:in `render' 
c:/Ruby193/incidents/app/controllers/incidents_controller.rb:24:in `block (2 lev 
els) in new' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/mime_responds.rb:196:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/mime_responds.rb:196:in `respond_to' 
c:/Ruby193/incidents/app/controllers/incidents_controller.rb:20:in `new' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/implicit_render.rb:4:in `send_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/base.rb:167:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/rendering.rb:10:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/callbacks.rb:18:in `block in process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:414:in `_run__322942522__process_action__447782570__callbacks' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:405:in `__run_callback' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:385:in `_run_process_action_callbacks' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:81:in `run_callbacks' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/callbacks.rb:17:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/rescue.rb:29:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/instrumentation.rb:30:in `block in process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications.rb:123:in `block in instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications/instrumenter.rb:20:in `instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/n 
otifications.rb:123:in `instrument' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/instrumentation.rb:29:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/params_wrapper.rb:206:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.4.rc1/lib/active_record/rai 
lties/controller_runtime.rb:18:in `process_action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/base.rb:121:in `process' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/abstract_controller 
/rendering.rb:45:in `process' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal.rb:203:in `dispatch' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal/rack_delegation.rb:14:in `dispatch' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_controller/m 
etal.rb:246:in `block in action' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/rou 
ting/route_set.rb:73:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/rou 
ting/route_set.rb:73:in `dispatch' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/rou 
ting/route_set.rb:36:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `b 
lock in call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `e 
ach' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `c 
all' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/rou 
ting/route_set.rb:600:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/best_standards_support.rb:17:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in 
`call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/head.rb:14:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/params_parser.rb:21:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/flash.rb:238:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:2 
05:in `context' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:2 
00:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/cookies.rb:338:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.4.rc1/lib/active_record/que 
ry_cache.rb:64:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.4.rc1/lib/active_record/con 
nection_adapters/abstract/connection_pool.rb:473:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/callbacks.rb:28:in `block in call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:405:in `_run__711941801__call__927210605__callbacks' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:405:in `__run_callback' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:385:in `_run_call_callbacks' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
allbacks.rb:81:in `run_callbacks' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/callbacks.rb:27:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/reloader.rb:65:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/remote_ip.rb:31:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/debug_exceptions.rb:16:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/show_exceptions.rb:56:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.4.rc1/lib/rails/rack/logger.rb: 
26:in `call_app' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.4.rc1/lib/rails/rack/logger.rb: 
16:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/request_id.rb:22:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in 
`call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.4.rc1/lib/active_support/c 
ache/strategy/local_cache.rb:72:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_dispatch/mid 
dleware/static.rb:62:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.4.rc1/lib/rails/engine.rb:479:i 
n `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.4.rc1/lib/rails/application.rb: 
220:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in 
`call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.4.rc1/lib/rails/rack/log_tailer 
.rb:17:in `call' 
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in 
`service' 
C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' 
C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' 
C:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread' 
    Rendered incidents/_new.html.erb (169.0ms) 
Completed 500 Internal Server Error in 178ms 

ActionView::Template::Error (c:/Ruby193/incidents/app/views/incidents/_new.html. 
erb:2: syntax error, unexpected ',', expecting keyword_end 
'); form_for(incident, :update=>'map_info'), :remote => true do |f| 
              ^
c:/Ruby193/incidents/app/views/incidents/_new.html.erb:23: syntax error, unexpec 
ted keyword_ensure, expecting $end): 
    1: <h1>New incident</h1> 
    2: <% form_for(incident, :update=>'map_info'), :remote => true do |f| %> 
    3: <p> 
    4:  <%= f.label :mountain %> <%= f.text_field :mountain %> 
    5: </p> 
    app/controllers/incidents_controller.rb:24:in `block (2 levels) in new' 
    app/controllers/incidents_controller.rb:20:in `new' 


    Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_d 
ispatch/middleware/templates/rescues/_trace.erb (5.0ms) 
    Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_d 
ispatch/middleware/templates/rescues/_request_and_response.erb (2.0ms) 
    Rendered C:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.4.rc1/lib/action_d 
ispatch/middleware/templates/rescues/template_error.erb within rescues/layout (1 
38.0ms) 
+0

这听起来像是在某些Ajax调用中出现HTTP 500错误。请将日志文件中的实际错误消息与堆栈跟踪一起发布。 –

+0

以下是错误:[14:29:07.279] GET http:// localhost:3000/incidents/new?latitude = 51.98036694779745&longitude = -93.515625 [HTTP/1.1 500 Internal Server Error 322ms] – ecs

+0

请在您的Rails日志文件[RAILS_ROOT/log/development.log)获取确切的错误消息和回溯,并将其添加到原始问题中。 –

回答

0

根据错误:

",":remote => true的面前,form_for(incident, :update=>'map_info')后面。删除它

好吧,让我们重新编码它。尝试:

<%= form_for incidents_url, :remote => true do |f| %> 

你要添加新的文件在事件称为new.js.erbincidents/new.js.erb)。通常它会被称为create.js.erb,但是您使用的是new action,而不是创建。

在那个文件里面,你写了更新div的jQuery代码。你

$(".class_name_of_div").prepend("<%= @incident.which_ever_attribute_you_want %>"); 

可能还需要改变你的控制器位:

def new 
    @incident = Incident.new 
    @incident.latitude = params[:latitude] 
    @incident.longitude = params[:longitude] 
    @incident.save 

    respond_to do |format| 
    format.html 
    format.js 
    end 
end 

更改部分太:

<%= render 'incidents/map', :incident => @incident %> 

告诉我是怎么回事。

+0

我试过了,它仍然不起作用。然后它会抱怨':remote'前面的冒号。它似乎也给控制器中的'新'部分和'新'动作提供了错误,但是看到这是从教程中给出的'答案代码'的代码,我不知道为什么它不工作! – ecs

+0

是的!非常感谢!!我将如何编辑以包含:update =>'map_info'? – ecs

+0

你想用map_info做什么? - 我从来没有使用轨道2 ..我可以告诉你如何在轨道3中做到这一点:) – Dol