0

Getting an obscure error which originates from the ActiveResource standard Rails library. The line within Rails causing this problem is given below along with the output. Any idea on how to resolve this problem please?

class Search < ActiveResource::Nestful::Base

  self.collection_name = "search"

  schema do
    string :type
    object :event
  end

def self.query(params)
   find(:all, :params => params)
end

def self.per_page
  3
end

def record
  attributes[attributes["type"]]
end
end

OUTPUT

Started GET "/search?utf8=%E2%9C%93&q=Hammersmith&location=&commit=Search" for 127.0.0.1         at 2012-09-17 15:10:53 +0100
Processing by SearchController#index as HTML
Parameters: {"utf8"=>"✓", "q"=>"Hammersmith", "location"=>"", "commit"=>"Search"}
Completed 500 Internal Server Error in 2343247ms

NoMethodError (undefined method `body' for #<Hash:0xbc3ee74>):
 activeresource (3.2.8) lib/active_resource/base.rb:901:in `find_every'
 activeresource (3.2.8) lib/active_resource/base.rb:814:in `find'
 app/models/search.rb:12:in `query'
 app/controllers/search_controller.rb:14:in `index'
 actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
 actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
 actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
 actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
 activesupport (3.2.8) lib/active_support/callbacks.rb:426:in `block in      _run__1005704495__process_action__837521650__callbacks'
 activesupport (3.2.8) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_208'
 app/controllers/application_controller.rb:55:in `block in with_oauth'
 /home/jaygemang/.rvm/gems/ruby-1.9.3-p194/bundler/gems/activeresource-nestful-3b28ffcfe788/lib/active_resource/nestful.rb:15:in `oauth'
Jones Agyemang
  • 1,230
  • 16
  • 15
  • sounds like you're calling body on the params Hash but this is a wild guess because I don't know your code... – three Sep 17 '12 at 17:00
  • Don't quote active record code quote your controller and model code where the problem occurs. The problem probably isn't in active record, it just ends there. what is in your search model at line 12? Are you calling find on a model instance rather than a model itself? Without seeing the code we can't help. – Kenny Grant Sep 17 '12 at 22:09

1 Answers1

2

I'd take a look in app/models/search.rb:12:in `query'

TTT
  • 6,505
  • 10
  • 56
  • 82
  • [code]class Search < ActiveResource::Nestful::Base self.collection_name = "search" schema do string :type object :event end def self.query(params) # binding.pry find(:all, :params => params) end def self.per_page 3 end def record attributes[attributes["type"]] end end – Jones Agyemang Sep 17 '12 at 15:23
  • I'm guessing it could be a Rails 3.2.8 bug??? As this system works fine when downgraded to Rails 3.0.3 – Jones Agyemang Sep 17 '12 at 16:03
  • @JonesAgyemang, please add your code snippet to your original question by editing it and appending the code. – the Tin Man Sep 17 '12 at 16:10