ruby-on-rails ruby devise rails-geocoder

ruby on rails - método undefined `model_name ''para TrueClass: Class para DeviseConfirmations(Rails 4, idear)



ruby-on-rails rails-geocoder (1)

En mi aplicación Rails, para guardar el país del usuario (usando la gema Geocoder) en la tabla de Usuario cuando el usuario se registra, y usando otra pregunta SO , he cambiado algo en mis controladores / confirmations_controller.rb pero estoy recibiendo un error grave. no entiendo ni logro resolver:

def after_sign_up_path_for(resource) if Devise.allow_insecure_sign_in_after_confirmation resource.update(user_country: request.location.country) after_sign_in_path_for(resource) else resource.update(user_country: request.location.country) root_path end end

Lo extraño es que el usuario se guarda con todo bien (incluido el país de usuario que yo quería) en mi base de datos local. Pero entonces algo debe suceder ya que recibo una página de error con el siguiente mensaje de error:

undefined method `model_name'' for TrueClass:Class

Todo el registro de errores:

(0.8ms) COMMIT (0.5ms) BEGIN SQL (1.3ms) UPDATE "users" SET "remember_created_at" = $1, "updated_at" = $2 WHERE "users"."id" = 427 [["remember_created_at", 2014-06-24 10:52:32 UTC], ["updated_at", 2014-06-24 12:52:32 +0200]] (0.7ms) COMMIT (0.4ms) BEGIN SQL (0.9ms) UPDATE "users" SET "last_sign_in_at" = $1, "current_sign_in_at" = $2, "last_sign_in_ip" = $3, "current_sign_in_ip" = $4, "sign_in_count" = $5, "updated_at" = $6 WHERE "users"."id" = 427 [["last_sign_in_at", 2014-06-24 10:52:32 UTC], ["current_sign_in_at", 2014-06-24 10:52:32 UTC], ["last_sign_in_ip", "24.193.83.1"], ["current_sign_in_ip", "24.193.83.1"], ["sign_in_count", 1], ["updated_at", 2014-06-24 12:52:32 +0200]] (0.7ms) COMMIT (0.4ms) BEGIN User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE (LOWER("users"."email") = LOWER(''[email protected]'') AND "users"."id" != 427) LIMIT 1 SQL (1.3ms) UPDATE "users" SET "user_country" = $1, "updated_at" = $2 WHERE "users"."id" = 427 [["user_country", "United States"], ["updated_at", 2014-06-24 12:52:32 +0200]] (0.7ms) COMMIT Completed 500 Internal Server Error in 4984ms NoMethodError - undefined method `model_name'' for TrueClass:Class: actionpack (4.0.5) lib/action_controller/model_naming.rb:9:in `model_name_from_record_or_class'' actionpack (4.0.5) lib/action_dispatch/routing/polymorphic_routes.rb:182:in `build_named_route_call'' actionpack (4.0.5) lib/action_dispatch/routing/polymorphic_routes.rb:120:in `polymorphic_url'' actionpack (4.0.5) lib/action_dispatch/routing/url_for.rb:159:in `url_for'' actionpack (4.0.5) lib/action_controller/metal/rendering.rb:68:in `_process_options'' actionpack (4.0.5) lib/action_controller/metal/streaming.rb:202:in `_process_options'' actionpack (4.0.5) lib/abstract_controller/rendering.rb:119:in `render_to_body'' actionpack (4.0.5) lib/action_controller/metal/rendering.rb:33:in `render_to_body'' actionpack (4.0.5) lib/action_controller/metal/renderers.rb:26:in `render_to_body'' actionpack (4.0.5) lib/abstract_controller/rendering.rb:97:in `render'' actionpack (4.0.5) lib/action_controller/metal/rendering.rb:16:in `render'' actionpack (4.0.5) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'' activesupport (4.0.5) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'' /home/mreisner/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'' activesupport (4.0.5) lib/active_support/core_ext/benchmark.rb:12:in `ms'' actionpack (4.0.5) lib/action_controller/metal/instrumentation.rb:41:in `block in render'' actionpack (4.0.5) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'' activerecord (4.0.5) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'' actionpack (4.0.5) lib/action_controller/metal/instrumentation.rb:40:in `render'' actionpack (4.0.5) lib/action_controller/metal/implicit_render.rb:10:in `default_render'' actionpack (4.0.5) lib/action_controller/metal/responder.rb:233:in `default_render'' actionpack (4.0.5) lib/action_controller/metal/responder.rb:161:in `to_html'' actionpack (4.0.5) lib/action_controller/metal/responder.rb:154:in `respond'' actionpack (4.0.5) lib/action_controller/metal/responder.rb:147:in `call'' actionpack (4.0.5) lib/action_controller/metal/mime_responds.rb:330:in `respond_with'' devise (3.2.4) app/controllers/devise/registrations_controller.rb:20:in `create'' actionpack (4.0.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'' actionpack (4.0.5) lib/abstract_controller/base.rb:189:in `process_action'' actionpack (4.0.5) lib/action_controller/metal/rendering.rb:10:in `process_action'' actionpack (4.0.5) lib/abstract_controller/callbacks.rb:18:in `block in process_action'' activesupport (4.0.5) lib/active_support/callbacks.rb:483:in `_run__1192109421260337467__process_action__callbacks'' activesupport (4.0.5) lib/active_support/callbacks.rb:80:in `run_callbacks'' actionpack (4.0.5) lib/abstract_controller/callbacks.rb:17:in `process_action'' actionpack (4.0.5) lib/action_controller/metal/rescue.rb:29:in `process_action'' actionpack (4.0.5) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'' activesupport (4.0.5) lib/active_support/notifications.rb:159:in `block in instrument'' activesupport (4.0.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'' activesupport (4.0.5) lib/active_support/notifications.rb:159:in `instrument'' actionpack (4.0.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action'' actionpack (4.0.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'' activerecord (4.0.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'' actionpack (4.0.5) lib/abstract_controller/base.rb:136:in `process'' actionpack (4.0.5) lib/abstract_controller/rendering.rb:44:in `process'' actionpack (4.0.5) lib/action_controller/metal.rb:195:in `dispatch'' actionpack (4.0.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'' actionpack (4.0.5) lib/action_controller/metal.rb:231:in `block in action'' actionpack (4.0.5) lib/action_dispatch/routing/route_set.rb:80:in `call'' actionpack (4.0.5) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'' actionpack (4.0.5) lib/action_dispatch/routing/route_set.rb:48:in `call'' actionpack (4.0.5) lib/action_dispatch/routing/mapper.rb:44:in `call'' actionpack (4.0.5) lib/action_dispatch/journey/router.rb:71:in `block in call'' actionpack (4.0.5) lib/action_dispatch/journey/router.rb:59:in `each'' actionpack (4.0.5) lib/action_dispatch/journey/router.rb:59:in `call'' actionpack (4.0.5) lib/action_dispatch/routing/route_set.rb:674:in `call'' warden (1.2.3) lib/warden/manager.rb:35:in `block in call'' warden (1.2.3) lib/warden/manager.rb:34:in `catch'' warden (1.2.3) lib/warden/manager.rb:34:in `call'' rack (1.5.2) lib/rack/etag.rb:23:in `call'' rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'' rack (1.5.2) lib/rack/head.rb:11:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/flash.rb:241:in `call'' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/cookies.rb:486:in `call'' activerecord (4.0.5) lib/active_record/query_cache.rb:36:in `call'' activerecord (4.0.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'' activerecord (4.0.5) lib/active_record/migration.rb:373:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'' activesupport (4.0.5) lib/active_support/callbacks.rb:373:in `_run__3240580690818246217__call__callbacks'' activesupport (4.0.5) lib/active_support/callbacks.rb:80:in `run_callbacks'' actionpack (4.0.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/reloader.rb:64:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'' better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'' better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'' better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'' actionpack (4.0.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'' railties (4.0.5) lib/rails/rack/logger.rb:38:in `call_app'' railties (4.0.5) lib/rails/rack/logger.rb:20:in `block in call'' activesupport (4.0.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'' activesupport (4.0.5) lib/active_support/tagged_logging.rb:26:in `tagged'' activesupport (4.0.5) lib/active_support/tagged_logging.rb:68:in `tagged'' railties (4.0.5) lib/rails/rack/logger.rb:20:in `call'' quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'' actionpack (4.0.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'' rack (1.5.2) lib/rack/runtime.rb:17:in `call'' activesupport (4.0.5) lib/active_support/cache/strategy/local_cache.rb:83:in `call'' rack (1.5.2) lib/rack/lock.rb:17:in `call'' rack (1.5.2) lib/rack/sendfile.rb:112:in `call'' railties (4.0.5) lib/rails/engine.rb:511:in `call'' railties (4.0.5) lib/rails/application.rb:97:in `call'' rack (1.5.2) lib/rack/lock.rb:17:in `call'' rack (1.5.2) lib/rack/content_length.rb:14:in `call'' rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'' /home/mreisner/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'' /home/mreisner/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'' /home/mreisner/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread''


intenta hacer esto

def after_sign_up_path_for(resource) if Devise.allow_insecure_sign_in_after_confirmation resource.update(user_country: request.location.country) super(resource) else resource.update(user_country: request.location.country) root_path end end