Hello,
I have a model that contains a polymorphic assocation, Ive called the
foreign key owner_id and the class descriptor owner_type. In my
controller I have defined conditions_for_collection in the hope to
determine the contents of the listing based upon a users form input.
Basically, I am trying to determine records to include based upon a
user selected id matching the id of records in a table more than one
association away. If it was a normal association I know I could
specify to eagerly load the table and then I could write something
like,
config.columns[:one_key_away] = [:two_keys_away]
then in conditions for collection I could write
'two_keys_aways.id = 7'
ie use the table name... in the select statement...
so can you do something like this w/ a polymorphic assocation so...
config.columns[:owner].includes = [:line_item, :worksheet]
so basically, my line_item and worksheet tables have
has_many :quotes, :as => :owner statements
I would love to somehow have my quotes table joined w/ line_items via
the owner_id field, something like
quotes.owner_id = line_items.id
and then to be able to specify to eagerly load line_item associations
such that I can do things like
line_item_types.line_item_category_id = X
where line_item belongs_to :line_item_type
I have been trying things like...
config.columns[:owner].includes = [{:line_item => :line_item_type},
{:worksheet => :project},
{:quote_request => {:line_item => :line_item_type}}]
But honestly I dont really understand the syntax with specifying
tables to include in this way, like does the hash key value
relationship related to the has_many, belongs_to relationship in the
models?
Is it even possible to do anything like what I am thinking?
I understand this is a pretty unclear message, if anybody has any
thoughts or suggestions I would really appreciate it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---