Ok, so, constantize is working perfectly and helping me to replace a
lot of evals in other places.
My next step in this is to figure out how to use STI, ez_where, and
pagination.
Before STI and ez_where, I was building the conditions and setting up
pagination (ignore the fact that it was a session variable–that’s
gone now):
@person_pages, @people = paginate :person, :order => ‘last_name ASC,
first_name’,
:per_page => 20, :conditions
=> session[:conditions]
So, now, I’m building my conditions (one example):
cond = Caboose::EZ::Condition.new :people do
any :people do
first_name =~ query
last_name =~ query
username =~ query
preferred_name =~ query
end
end
And I could do the find like to:
@people = person_type.constantize.find :all, :order => ‘last_name ASC,
first_name’, :conditions => cond.to_sql
How does this fit into pagination? Yes, I can just put cond.to_sql in
for the condition, but I want to make sure I’m searching on the right
model. This doesn’t work:
@person_pages, @people = paginate person_type, :order => ‘last_name
ASC, first_name’,
:per_page => 20, :conditions =>
cond.to_sql
Nor does person_type.constantize. I think I tried adding the type to
the condition, but when searching for Employees, it didn’t translate
to Staff and Faculty. Should I have some sort of translation like
Rick suggested and add it to the ez_where conditions?
I’m just trying to figure out if I can do the equivalent of
Employee.find without resorting to that. Not that it’s so bad, but
the Employee.find searches seem more elegant.
Thanks!
Sean