flyerhzm/switch_user

NoMethodError - undefined method `all' for #<SwitchUser::GuestDataSource:0x007fd8d426f138>

Closed this issue · 3 comments

Hi,
Thanks for the gem, it's been super useful.
I started having this issue when I updated to 1.0. I'm on Rails 4.2.2, Ruby 2.2.1, Devise 3.5.1. It won't load the switch_user_select.
Thanks!
ale

Completed 500 Internal Server Error in 127ms (ActiveRecord: 0.0ms)
SwitchUser::GuestDataSource:0x007fd8d426f138>
NoMethodError - undefined method all' for #<SwitchUser::GuestDataSource:0x007fd8d426f138>: switch_user (1.0.0) lib/switch_user/data_source.rb:10:inblock in all'
switch_user (1.0.0) lib/switch_user/data_source.rb:10:in each' switch_user (1.0.0) lib/switch_user/data_source.rb:10:inflat_map'
switch_user (1.0.0) lib/switch_user/data_source.rb:10:in all' switch_user (1.0.0) lib/switch_user.rb:41:inall_users'
switch_user (1.0.0) app/helpers/switch_user_helper.rb:14:in switch_user_select' app/views/layouts/one-page.html.erb:29:in_app_views_layouts_one_page_html_erb___3458226017543812090_70284626163620'
actionview (4.2.2) lib/action_view/template.rb:145:in block in render' activesupport (4.2.2) lib/active_support/notifications.rb:166:ininstrument'
actionview (4.2.2) lib/action_view/template.rb:333:in instrument' actionview (4.2.2) lib/action_view/template.rb:143:inrender'
actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:66:in render_with_layout' actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:52:inrender_template'
actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:14:in render' actionview (4.2.2) lib/action_view/renderer/renderer.rb:42:inrender_template'
actionview (4.2.2) lib/action_view/renderer/renderer.rb:23:in render' actionview (4.2.2) lib/action_view/rendering.rb:100:in_render_template'
actionpack (4.2.2) lib/action_controller/metal/streaming.rb:217:in _render_template' actionview (4.2.2) lib/action_view/rendering.rb:83:inrender_to_body'
actionpack (4.2.2) lib/action_controller/metal/rendering.rb:32:in render_to_body' actionpack (4.2.2) lib/action_controller/metal/renderers.rb:37:inrender_to_body'
actionpack (4.2.2) lib/abstract_controller/rendering.rb:25:in render' actionpack (4.2.2) lib/action_controller/metal/rendering.rb:16:inrender'
actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:44:in block (2 levels) in render' activesupport (4.2.2) lib/active_support/core_ext/benchmark.rb:12:inblock in ms'
/Users/alexandrethome/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in realtime' activesupport (4.2.2) lib/active_support/core_ext/benchmark.rb:12:inms'
actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:44:in block in render' actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:87:incleanup_view_runtime'
activerecord (4.2.2) lib/active_record/railties/controller_runtime.rb:25:in cleanup_view_runtime' actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:43:inrender'
actionpack (4.2.2) lib/action_controller/metal/implicit_render.rb:10:in default_render' actionpack (4.2.2) lib/action_controller/metal/implicit_render.rb:5:insend_action'
actionpack (4.2.2) lib/abstract_controller/base.rb:198:in process_action' actionpack (4.2.2) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (4.2.2) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.2.2) lib/active_support/callbacks.rb:117:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:117:in call' activesupport (4.2.2) lib/active_support/callbacks.rb:555:inblock (2 levels) in compile'
activesupport (4.2.2) lib/active_support/callbacks.rb:505:in call' activesupport (4.2.2) lib/active_support/callbacks.rb:505:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:498:in block (2 levels) in around' activesupport (4.2.2) lib/active_support/callbacks.rb:313:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:313:in block (2 levels) in halting' browser-timezone-rails (0.0.8) lib/browser-timezone-rails.rb:14:inset_time_zone'
activesupport (4.2.2) lib/active_support/callbacks.rb:432:in block in make_lambda' activesupport (4.2.2) lib/active_support/callbacks.rb:312:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:312:in block in halting' activesupport (4.2.2) lib/active_support/callbacks.rb:497:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:497:in block in around' activesupport (4.2.2) lib/active_support/callbacks.rb:505:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:505:in call' activesupport (4.2.2) lib/active_support/callbacks.rb:92:in_run_callbacks'
activesupport (4.2.2) lib/active_support/callbacks.rb:776:in _run_process_action_callbacks' activesupport (4.2.2) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.2) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.2.2) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:32:in block in process_action' activesupport (4.2.2) lib/active_support/notifications.rb:164:inblock in instrument'
activesupport (4.2.2) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.2.2) lib/active_support/notifications.rb:164:ininstrument'
actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.2.2) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action'
activerecord (4.2.2) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.2.2) lib/abstract_controller/base.rb:137:inprocess'
actionview (4.2.2) lib/action_view/rendering.rb:30:in process' actionpack (4.2.2) lib/action_controller/metal.rb:196:indispatch'
actionpack (4.2.2) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.2.2) lib/action_controller/metal.rb:237:inblock in action'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:in call' actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:indispatch'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:43:in serve' actionpack (4.2.2) lib/action_dispatch/journey/router.rb:43:inblock in serve'
actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in each' actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:inserve'
actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:819:in call' bullet (4.14.7) lib/bullet/rack.rb:12:incall'
warden (1.2.3) lib/warden/manager.rb:35:in block in call' warden (1.2.3) lib/warden/manager.rb:34:incatch'
warden (1.2.3) lib/warden/manager.rb:34:in call' rack (1.6.4) lib/rack/etag.rb:24:incall'
rack (1.6.4) lib/rack/conditionalget.rb:25:in call' rack (1.6.4) lib/rack/head.rb:13:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.2.2) lib/action_dispatch/middleware/flash.rb:260:incall'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in context' rack (1.6.4) lib/rack/session/abstract/id.rb:220:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/cookies.rb:560:in call' activerecord (4.2.2) lib/active_record/query_cache.rb:36:incall'
activerecord (4.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in call' activerecord (4.2.2) lib/active_record/migration.rb:378:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.2.2) lib/active_support/callbacks.rb:88:incall'
activesupport (4.2.2) lib/active_support/callbacks.rb:88:in _run_callbacks' activesupport (4.2.2) lib/active_support/callbacks.rb:776:in_run_call_callbacks'
activesupport (4.2.2) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.2.2) lib/action_dispatch/middleware/remote_ip.rb:78:incall'
rollbar (1.5.3) lib/rollbar/middleware/rails/rollbar.rb:24:in block in call' rollbar (1.5.3) lib/rollbar.rb:799:inscoped'
rollbar (1.5.3) lib/rollbar/middleware/rails/rollbar.rb:22:in call' better_errors (2.1.1) lib/better_errors/middleware.rb:84:inprotected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in better_errors_call' better_errors (2.1.1) lib/better_errors/middleware.rb:57:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' rollbar (1.5.3) lib/rollbar/middleware/rails/show_exceptions.rb:22:incall_with_rollbar'
actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.2.2) lib/rails/rack/logger.rb:38:incall_app'
railties (4.2.2) lib/rails/rack/logger.rb:22:in call' quiet_assets (1.1.0) lib/quiet_assets.rb:27:incall_with_quiet_assets'
request_store (1.1.0) lib/request_store/middleware.rb:8:in call' actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.6.4) lib/rack/methodoverride.rb:22:in call' rack (1.6.4) lib/rack/runtime.rb:18:incall'
activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' rack (1.6.4) lib/rack/lock.rb:17:incall'
actionpack (4.2.2) lib/action_dispatch/middleware/static.rb:113:in call' rack (1.6.4) lib/rack/sendfile.rb:113:incall'
railties (4.2.2) lib/rails/engine.rb:518:in call' railties (4.2.2) lib/rails/application.rb:164:incall'
rack (1.6.4) lib/rack/content_length.rb:15:in call' thin (1.6.3) lib/thin/connection.rb:86:inblock in pre_process'
thin (1.6.3) lib/thin/connection.rb:84:in catch' thin (1.6.3) lib/thin/connection.rb:84:inpre_process'
thin (1.6.3) lib/thin/connection.rb:53:in process' thin (1.6.3) lib/thin/connection.rb:39:inreceive_data'
eventmachine (1.0.7) lib/eventmachine.rb:187:in run_machine' eventmachine (1.0.7) lib/eventmachine.rb:187:inrun'
thin (1.6.3) lib/thin/backends/base.rb:73:in start' thin (1.6.3) lib/thin/server.rb:162:instart'
rack (1.6.4) lib/rack/handler/thin.rb:19:in run' rack (1.6.4) lib/rack/server.rb:286:instart'
railties (4.2.2) lib/rails/commands/server.rb:80:in start' railties (4.2.2) lib/rails/commands/commands_tasks.rb:80:inblock in server'
railties (4.2.2) lib/rails/commands/commands_tasks.rb:75:in tap' railties (4.2.2) lib/rails/commands/commands_tasks.rb:75:inserver'
railties (4.2.2) lib/rails/commands/commands_tasks.rb:39:in run_command!' railties (4.2.2) lib/rails/commands.rb:17:in<top (required)>'
bin/rails:8:in require' bin/rails:8:in

'
16:18:56 web.1 |

@alesthome please try master branch

@flyerhzm thanks for the quick response. Yeah, now it works (from master). The only other thing that changed is that now it doesn't work to pass a method for the available_users_names like it used to:

config.available_users_names = { :user => :switch_identifier }

User.rb
def switch_identifier
"#{role} | #{email} (id: #{id})"
end

thanks again!

@alesthome it's also fixed in version 1.0.1