Ruby app responding until stack goes too deep
I'm at a loss here. I have a fairly simple thing going but seem to run into problems a lot with this. I have straight forward web crawler in the works. People post requests and send it on to the queue. If they want to query whats in the queue: the route is
127.0.0.1:8080/requests/id/1.json
response is the action (def) CrawlerController is controller. request is the model.
Heres the route: (although I don't think its relevant)
match 'requests/id/:id' => 'crawler#response'
And here is the def within the controller:
def response
@request = Request.find(params[:id])
respond_to do |format|
#format.html { render :action => "new"}
format.json { render :json => @request.to_json }
end
end
The error I'm getting is stack level too deep. If i look at the console output:
EDIT: lines 21 and 19 are the @respond to do and format.json
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "requests".* FROM "requests" WHERE "requests"."id" = 1 LIMIT 1
Completed 500 Internal Server Error in 2688ms
SystemStackError (stack level too deep):
app/controllers/crawler_controller.rb:21:in `response'
app/controllers/crawler_controller.rb:19:in `response'
app/controllers/crawler_controller.rb:21:in `response'
app/controllers/c开发者_高级运维rawler_controller.rb:19:in `response'
app/controllers/crawler_controller.rb:21:in `response'
app/controllers/crawler_controller.rb:19:in `response'
pretty strange huh?
Try renaming your method from response
to something else. I think response
might be used by Rails for something else.
Try renaming your variable from @request
to something else. I think @request
might be used by Rails for something else.
Also try renaming your action from response
to something else. I think response
might be used by Rails for something else.
精彩评论