iOSとレールでRestkitを使いこなしています。なぜ私のコードが機能していないのかわかりません。基本的に私は、iOSでProfileModelクラスとIセットアップそれのためのオブジェクトのマッピングを持っており、以下のようにメソッドを呼び出します。RestKit putObjectがRailsモデルで動作しない
-(IBAction)saveButton:(id)sender
{
NSLog(@"Editprofile save button clicked");
RKObjectMapping *objectmappingSerialProfile = [RKObjectMapping mappingForClass:[ProfileModel class]];
[objectmappingSerialProfile mapKeyPath:@"location" toAttribute:@"country"];
[objectmappingSerialProfile mapKeyPath:@"descriptionText" toAttribute:@"description"];
[objectmappingSerialProfile mapKeyPath:@"facebookID" toAttribute:@"facebook"];
[objectmappingSerialProfile mapKeyPath:@"username" toAttribute:@"name"];
[objectmappingSerialProfile mapKeyPath:@"twitterID" toAttribute:@"twittername"];
[objectmappingSerialProfile mapKeyPath:@"website" toAttribute:@"website"];
NSDictionary *authTokenParam = [NSDictionary dictionaryWithKeysAndObjects:@"auth_token",@"pb9mp459iUj6NnmPk5C2", nil];
[[RKObjectManager sharedManager].router routeClass:[ProfileModel class] toResourcePath:[@"/modifyProfile.json" appendQueryParams:authTokenParam] forMethod:RKRequestMethodPUT];
[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:objectmappingSerialProfile forClass:[ProfileModel class]];
[[RKObjectManager sharedManager] setSerializationMIMEType:RKMIMETypeJSON];
[[RKObjectManager sharedManager] putObject:self.navProfile delegate:nil];
}
を私は
Xcodeでデバッガウィンドウで、次のエラーメッセージが表示されますこのコードを実行すると、2012-03-20 23:51:22.815 Someprogram[3684:fe03] Editprofile save button clicked
2012-03-20 23:51:22.921 Someprogram[3684:fe03] W restkit.network:RKObjectLoader.m:241 Unable to find parser for MIME Type 'text/html'
2012-03-20 23:51:22.921 Someprogram[3684:fe03] W restkit.network:RKObjectLoader.m:262 Encountered unexpected response with status code: 500 (MIME Type: text/html)
私はレール0.9.3を使用して、しかし
Started PUT "/modifyProfile.json?auth_token=pb9mp459iUj6NnmPk5C2" for 127.0.0.1 at 2012-03-20 23:51:22 +0000
Processing by ProfilesController#update as JSON
Parameters: {"country"=>"earth2", "name"=>"AdiUpdated2", "twittername"=>"abc", "website"=>"hmmm", "description"=>"abcc", "facebook"=>"abcd", "auth_token"=>"pb9mp459iUj6NnmPk5C2", "profile"=>{"name"=>"AdiUpdated2", "description"=>"abcc", "twittername"=>"abc", "facebook"=>"abcd", "website"=>"hmmm", "country"=>"earth2"}}
WARNING: Can't verify CSRF token authenticity
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 9 LIMIT 1
(0.1ms) begin transaction
SOLR Request (2.2ms) [ path=#<RSolr::Client:0x007fc565d65f88> parameters={data: <?xml version="1.0" encoding="UTF-8"?><add><doc><field name="id">User 9</field><field name="type">User</field><field name="type">ActiveRecord::Base</field><field name="class_name">User</field></doc></add>, headers: {"Content-Type"=>"text/xml"}, method: post, params: {:wt=>:ruby}, query: wt=ruby, path: update, uri: http://localhost:8982/solr/update?wt=ruby, open_timeout: , read_timeout: } ]
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 22ms
Errno::ECONNREFUSED (Connection refused - connect(2)):
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:762:in `initialize'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:762:in `open'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:762:in `connect'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:744:in `start'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1284:in `request'
rsolr (1.0.7) lib/rsolr/connection.rb:15:in `execute'
sunspot_rails (1.3.0) lib/sunspot/rails/solr_instrumentation.rb:14:in `block in execute_with_as_instrumentation'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
sunspot_rails (1.3.0) lib/sunspot/rails/solr_instrumentation.rb:12:in `execute_with_as_instrumentation'
rsolr (1.0.7) lib/rsolr/client.rb:166:in `execute'
rsolr (1.0.7) lib/rsolr/client.rb:161:in `send_and_receive'
(eval):2:in `post'
rsolr (1.0.7) lib/rsolr/client.rb:67:in `update'
rsolr (1.0.7) lib/rsolr/client.rb:87:in `add'
sunspot (1.3.0) lib/sunspot/indexer.rb:101:in `add_documents'
sunspot (1.3.0) lib/sunspot/indexer.rb:26:in `add'
sunspot (1.3.0) lib/sunspot/session.rb:91:in `index'
sunspot (1.3.0) lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `index'
sunspot (1.3.0) lib/sunspot.rb:184:in `index'
sunspot_rails (1.3.0) lib/sunspot/rails/searchable.rb:372:in `solr_index'
sunspot_rails (1.3.0) lib/sunspot/rails/searchable.rb:470:in `perform_index_tasks'
activesupport (3.2.1) lib/active_support/callbacks.rb:427:in `_run__3891665525441134440__save__2817329553089450813__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.1) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.2.1) lib/active_record/persistence.rb:84:in `save'
activerecord (3.2.1) lib/active_record/validations.rb:50:in `save'
activerecord (3.2.1) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (3.2.1) lib/active_record/transactions.rb:241:in `block (2 levels) in save'
activerecord (3.2.1) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.2.1) lib/active_record/connection_adapters/abstract/database_statements.rb:190:in `transaction'
activerecord (3.2.1) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.1) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.1) lib/active_record/transactions.rb:241:in `block in save'
activerecord (3.2.1) lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
activerecord (3.2.1) lib/active_record/transactions.rb:240:in `save'
devise (2.0.4) lib/devise/models/rememberable.rb:58:in `forget_me!'
devise (2.0.4) lib/devise/controllers/rememberable.rb:32:in `forget_me'
devise (2.0.4) lib/devise/hooks/forgetable.rb:7:in `block in <top (required)>'
warden (1.1.1) lib/warden/hooks.rb:14:in `call'
warden (1.1.1) lib/warden/hooks.rb:14:in `block in _run_callbacks'
warden (1.1.1) lib/warden/hooks.rb:9:in `each'
warden (1.1.1) lib/warden/hooks.rb:9:in `_run_callbacks'
warden (1.1.1) lib/warden/manager.rb:53:in `_run_callbacks'
warden (1.1.1) lib/warden/proxy.rb:243:in `block in logout'
warden (1.1.1) lib/warden/proxy.rb:241:in `each'
warden (1.1.1) lib/warden/proxy.rb:241:in `logout'
devise (2.0.4) lib/devise/controllers/helpers.rb:156:in `sign_out_all_scopes'
devise (2.0.4) lib/devise/controllers/helpers.rb:261:in `handle_unverified_request'
actionpack (3.2.1) lib/action_controller/metal/request_forgery_protection.rb:78:in `verify_authenticity_token'
activesupport (3.2.1) lib/active_support/callbacks.rb:407:in `_run__1101336661489218557__process_action__1327857175712471554__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.1) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.1) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.1) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.1) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.1) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.1) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `call'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:66:in `dispatch'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.1) lib/journey/router.rb:68:in `block in call'
journey (1.0.1) lib/journey/router.rb:56:in `each'
journey (1.0.1) lib/journey/router.rb:56:in `call'
actionpack (3.2.1) lib/action_dispatch/routing/route_set.rb:589:in `call'
warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
warden (1.1.1) lib/warden/manager.rb:34:in `catch'
warden (1.1.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.1) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `_run__632645031902289657__call__2817329553089450813__callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.1) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.2.1) lib/rails/engine.rb:479:in `call'
railties (3.2.1) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/Adi/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rendered /Users/Adi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (3.9ms)
Rendered /Users/Adi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered /Users/Adi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (6.9ms)
を次のように私は同じPUTリクエストを実行するには、mac上でRESTClientと呼ばれるプログラムを使用する場合は、レールのウィンドウの私の応答が、あります。これは、正常に動作し、ウィンドウ内のRailsの応答は次のとおりです。
Started PUT "/modifyProfile.json?auth_token=pb9mp459iUj6NnmPk5C2" for 127.0.0.1 at 2012-03-21 00:02:57 +0000
Processing by ProfilesController#update as JSON
Parameters: {"country"=>"earth22", "description"=>"abcc", "twittername"=>"abc", "facebook"=>"abcd", "website"=>"hmmm", "name"=>"AdiUpdated2", "auth_token"=>"pb9mp459iUj6NnmPk5C2", "profile"=>{"name"=>"AdiUpdated2", "description"=>"abcc", "twittername"=>"abc", "facebook"=>"abcd", "website"=>"hmmm", "country"=>"earth22"}}
WARNING: Can't verify CSRF token authenticity
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."authentication_token" = 'pb9mp459iUj6NnmPk5C2' LIMIT 1
Profile Load (0.1ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = 9 LIMIT 1
(0.0ms) begin transaction
(0.0ms) commit transaction
Rendered profiles/update.json.rabl (1.9ms)
Completed 200 OK in 9ms (Views: 4.4ms | ActiveRecord: 0.4ms | Solr: 0.0ms)
私は見ています唯一の違いは、問題のいくつかの並べ替えを作成している太陽黒点のSolrとは何かです。しかし、リクエストコードは同じであるように思われます。なぜRailsはこれとは異なった応答をしていますか?誰でも助けてくれますか?
コードの長い行について謝罪しますが、私が何をしているか見てみたいと思うかもしれませんか?
多くのおかげでありがたい。