Guest User

Untitled

a guest
May 26th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. # So, in erb templates and partials I want to use both @work_queue and @users.
  2. # @work_queue is visible, but @users is not.
  3. # Moving the declaration of @users to the protected method makes @users available.
  4. # I don't understand the scoping.
  5.  
  6. # Fails when RAILS_ENV = test, success for development/production
  7. class Queues::WorkQueuesController < ApplicationController
  8. layout 'basic'
  9. before_filter :find_work_queue, :only => [:show, :refresh_panes]
  10.  
  11. def show
  12. if @work_queue.nil?
  13. flash[:exclamation] = "You do not have access to that work queue."
  14. redirect_to secure_back
  15. end
  16. @users = @work_queue.team.users.inject({}) { |users, user| users[user.id] = user; users } if @work_queue
  17. end
  18.  
  19. protected
  20. def find_work_queue
  21. @work_queue = sentry.user.active_work_queues.detect {|q| q.id == params[:id].to_i}
  22. end
  23.  
  24. end
Add Comment
Please, Sign In to add comment