I can't quite figure out how I can make this work properly.
I'm in my login_controller.rb
If I use cond = EZ::Where::Condition.new cond = "term_date IS NULL".to_c + c{employment_type === ['CLIENT', 'CSW', 'F/T','P/T', 'INT', 'PRN']} @personnel = Personnel.find(:all, :conditions => cond.to_sql, :order => 'last_name, first_name')
This works but is not very dry since I use this in multiple places.
So in my personnel.rb model, I have something identical... def current cond = EZ::Where::Condition.new cond = "term_date IS NULL".to_c + c{employment_type === ['CLIENT', 'CSW', 'F/T','P/T', 'INT', 'PRN']} Personnel.find(:all, :conditions => cond.to_sql, :order => 'last_name, first_name') end
but if I try to use @personnel = Personnel.current
in my login_controller.rb, I get the 'undefined method 'current' for Personnel:Class error - even if I 'require "personnel" in my login.rb model (which I wouldn't think necessary since login.rb 'has_one :personnel')
Why doesn't the definition in the personnel model work in another controller?
Craig