i'm getting kind of nil error; tells me it's calling nil
on 'name'
, not show me where.
here routes:
# mobile api map.namespace :mobile_api |api| api.resources :updates, :only => [ :index ] api.resources :checkouts, :collection => { :reading_progress => :put } end
i using postman debug api call.
here data send postman raw, json put
url localhost:3000/mobile_api/checkouts/reading_progress
:
{"title":"awesome post!", "tags": ["blue", "jeans"] }
when remove json data , make request no data goes through controller.
class mobileapi::checkoutscontroller < applicationcontroller def reading_progress binding.pry end end
as add data postman send, error:
|ruby-1.8.7-p371| ubuntu-francois in ~/sites/mds ± |old-state ✗| → ./script/server => booting mongrel => rails 2.3.17 application starting on http://0.0.0.0:3000 /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rubyzip2-2.0.2/lib/zip/version.rb:2: warning: initialized constant version => call -d detach => ctrl-c shutdown server sql (0.1ms) set names 'utf8' sql (0.1ms) set sql_auto_is_null=0 error occurred while parsing request parameters. contents: {"title":"awesome post!", "tags": ["blue", "jeans"] } /!\ failsafe /!\ mon jul 15 17:26:37 +0200 2013 status: 500 internal server error undefined method `name' nil:nilclass /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/whiny_nil.rb:52:in `method_missing' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/xml_mini/rexml.rb:29:in `merge_element!' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/xml_mini/rexml.rb:18:in `parse' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/xml_mini.rb:12:in `__send__' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/xml_mini.rb:12:in `parse' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/core_ext/hash/conversions.rb:171:in `from_xml' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/params_parser.rb:34:in `parse_formatted_parameters' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/params_parser.rb:11:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/session/abstract_store.rb:177:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:29:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activerecord-2.3.17/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:9:in `cache' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:28:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activerecord-2.3.17/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/failsafe.rb:26:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/lock.rb:11:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/lock.rb:11:in `synchronize' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/lock.rb:11:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:114:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/reloader.rb:34:in `run' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:108:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rails-2.3.17/lib/rails/rack/static.rb:31:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/urlmap.rb:47:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/urlmap.rb:41:in `each' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/urlmap.rb:41:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rails-2.3.17/lib/rails/rack/log_tailer.rb:17:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/content_length.rb:13:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/chunked.rb:15:in `call' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/handler/mongrel.rb:67:in `process' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rack-1.1.6/lib/rack/handler/mongrel.rb:38:in `run' /home/francois/.rvm/gems/ruby-1.8.7-p371/gems/rails-2.3.17/lib/commands/server.rb:111 ./script/server:3:in `require' ./script/server:3
hope can out.
the error occurring here:
/home/francois/.rvm/gems/ruby-1.8.7-p371/gems/activesupport-2.3.17/lib/active_support/xml_mini/rexml.rb:29:in `merge_element!'
the top line of stack trace active support trying nilclass
errors.
what's interesting rexml being invoked parse json. it's possible request headers aren't set correctly json string. ensure header set:
content-type: application/json
Comments
Post a Comment