PewePro / alef-tng

Alef strikes back
2 stars 3 forks source link

NoMethodError: undefined method `where' for #<Array:0x007fd69aa8f1b0> #191

Closed PewePro closed 8 years ago

PewePro commented 8 years ago

View details in Rollbar: https://rollbar.com/AlefTNG/AlefTNG/items/35/


NoMethodError: undefined method `where' for #<Array:0x007fd69aa8f1b0>
  File "/home/aleftng/deploy/aleftng/releases/20160409222409/app/controllers/weeks_controller.rb", line 28, in show
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/implicit_render.rb", line 4, in send_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/abstract_controller/base.rb", line 198, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/rendering.rb", line 10, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/abstract_controller/callbacks.rb", line 20, in block in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 117, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 117, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 555, in block (2 levels) in compile
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 505, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 505, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 92, in __run_callbacks__
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 778, in _run_process_action_callbacks
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/callbacks.rb", line 81, in run_callbacks
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/abstract_controller/callbacks.rb", line 19, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/rescue.rb", line 29, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/instrumentation.rb", line 32, in block in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb", line 164, in block in instrument
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications/instrumenter.rb", line 20, in instrument
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications.rb", line 164, in instrument
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/instrumentation.rb", line 30, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/params_wrapper.rb", line 250, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/railties/controller_runtime.rb", line 18, in process_action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/abstract_controller/base.rb", line 137, in process
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionview-4.2.4/lib/action_view/rendering.rb", line 30, in process
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal.rb", line 196, in dispatch
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal/rack_delegation.rb", line 13, in dispatch
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_controller/metal.rb", line 237, in block in action
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb", line 76, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb", line 76, in dispatch
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb", line 45, in serve
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/journey/router.rb", line 43, in block in serve
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/journey/router.rb", line 30, in each
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/journey/router.rb", line 30, in serve
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb", line 821, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/middleware_tracing.rb", line 96, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/rack/agent_hooks.rb", line 30, in traced_call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/middleware_tracing.rb", line 96, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/rack/browser_monitoring.rb", line 32, in traced_call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/middleware_tracing.rb", line 96, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb", line 35, in block in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb", line 34, in catch
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb", line 34, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/middleware_tracing.rb", line 96, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/etag.rb", line 24, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/middleware_tracing.rb", line 96, in call
  File "/home/aleftng/deploy/aleftng/shared/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/conditionalget.rb",
mlabaj commented 8 years ago

@veronikagondova Pada to tu: https://github.com/PewePro/alef-tng/blob/b46b301/app/controllers/weeks_controller.rb#L28

mlabaj commented 8 years ago

@veronikagondova Vyzera to, ze v tom momente, ked sa snazis na tom robit where, uz to nie je AREL objekt (na ktorom by sa dali volat arel metody), ale obycajny Array. Totiz ten select o par riadkov vyssie uz nerobi nad databazou, to je enumerable metoda, najskor sa odpali dotaz a select je uz potom iteracia v ruby, aha:

Room.all.select{ |x| x.state = "do_not_use" }.class
=> Array

vs.

Room.all.where(state: "do_not_use").class
=> Room::ActiveRecord_Relation

Nad tym druhym treba miesto toho class potom spravit take, first, all, atd. aby sa to odpalilo do DB. Takisto to prve robi: SELECT "rooms".* FROM "rooms" kdezto to druhe: SELECT "rooms".* FROM "rooms" WHERE "rooms"."state" = $1 [["state", "do_not_use"]]

Cize je najlepsie mat z toho co najdlhsie Relation a retazit nad tym where (vyberie sa z DB co vyhovuje podmienkam), nez select, ktory najskor vytiahne z DB vsetko co ma doteraz naretazene a potom v ruby iteruje. Tak ci tak, treba fixnut to volanie where na tom riadku kde to pada.

mlabaj commented 8 years ago

@veronikagondova

veronikagondova commented 8 years ago

@mlabaj pada to na https://github.com/PewePro/alef-tng/blob/b46b301/app/controllers/weeks_controller.rb#L30 ale v masteri uz je iny kod. Tak neviem, ze kde je problem.

petergaspar commented 8 years ago

asi nie je ten kod nasadeny :trollface: :)

veronikagondova commented 8 years ago

Tak, v takom pripade to ja asi nevyriesim :D

mlabaj commented 8 years ago

Interestingly, ano :trolleybus: Spravte uz niekto (wink @petergaspar) full CI.

mlabaj commented 8 years ago

Niekto iny to nasadil