Perhaps you guys can help me out on something to do with this.

I'd like to allow the end user to adjust the where clause and includes to 
the query.  The where clause is simple unless they want to filter on sub 
tables.  Thats where the includes clause comes into play.

Say we have 3 modles all associated in one-many relationship.  IE

Model1
  has_many :model2
end

Model2
  belongs_to :model1
  has_many :model3
end

Model3
  belongs_to :model2
end

I know in code I can do the following

Model1.find(:all, :where => "model3.name = 'test'", :includes => [:model2, 
{:model2 => :model3}]

The where clause is a string so allowing the use to specify this for a 
report and save it to the db is easy.  I can use the following in my report 
controller to put it to use.

      query = Kernel.const_get(@report.modelname).scoped
      query = query.where(@report.whereclause) if 
[email protected]?
      @robj = query.all

The problem is the includes.  Since it uses symbols, hashes etc. I can't 
figure out how to pass a string the user enters that is stored in the db to 
the :includes clause.

If I only include model2 (ie a direct relationship) I can use a simple 
string with the relationship name but anything further I can't get to work.

Bob

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/hobousers/-/SBWGNGZ99ZYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to