在rails中发布活动资源。错误500

时间:2011-07-11 15:35:43

标签: ruby-on-rails post activeresource

尝试使用活动资源。我这里有一个非常基本的程序。一个应用程序在端口9000上运行,另一个在20000上运行。我正在尝试将活动资源从9000发布到20000.

我的活跃资源非常简单:

class Request < ActiveResource::Base
  self.site = "http://127.0.0.1:20000/requests/add"
end

又在客户页面的索引中调用

@request = Request.new (:url => "www.activeresourcetester.com",:depth => 34)
@request.save

其他网络应用程序非常空白。我曾经有过:

 def add_Request
    @request = User_Request.new({:url => params[:url], :depth => params[:depth] })
    if @request.save
    #ok
      puts "OBJECT CREATED AND SAVED"
      #error
      puts "SOMETHING WENT WRONG WITH OBJECT CREATION"

它现在已经消失,因为这不起作用,因为活动资源将达到20000,然后20000正在制作它自己的。我怀疑我需要在这里处理输入?

路线如下:

  match 'requests/add/requests' =>'crawler#add_Request'
  match  '/requests/add' => 'crawler#add_Request'

第一个的原因是,如果我没有它,我的

会出现404错误
(No route matches "/requests/add/requests.xml"):

这是2个端口/服务器的堆栈跟踪

客户9000     在2011年7月11日星期一16:27:16 +0100开始获取127.0.0.1的“/ requests /”       由RequestsController #index处理为HTML     在130毫秒内完成了500内部服务器错误

ActiveResource::ServerError (Failed.  Response code = 500.  Response message = Internal Server Error .):
  app/controllers/requests_controller.rb:15:in `index'

Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (5.1ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.5ms)

和服务器20000:

Started POST "/requests/add/requests.xml" for 127.0.0.1 at Mon Jul 11 16:27:16 +0100 2011
  Processing by CrawlerController#add_Request as XML
  Parameters: {"request"=>{"depth"=>34, "url"=>"www.activeresourcetester.com"}}
Completed 500 Internal Server Error in 5ms

ActionView::MissingTemplate (Missing template crawler/add_Request with {:locale=>[:en, :en], :handlers=>[:erb, :rxml, :builder, :rjs, :rhtml], :formats=>[:xml]} in view paths "/Users/shanemoore/RubymineProjects/Crawler1.5/app/views"):


Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.6ms)

为什么我收到500错误的任何想法? 我应该编写服务器端的代码

0 个答案:

没有答案