in my project.rb model, I am trying to create a scope with a dynamic variable:
scope :instanceprojects, lambda { where("projects.instance_id = ?", current_user.instance_id) }
I get the following error:
undefined local variable or method `current_user' for #<Class:0x102fe3af0>
Where in the controller can I access current_user.instance_id ... Is there a reason why the model cannot access it and how to access it? Also, is this a suitable place to create the area as described above, or does it belong to the controller?
ruby-on-rails activerecord ruby-on-rails-3
AnApprentice Sep 18 '10 at 17:47 2010-09-18 17:47
source share