Hi, I've defined a polymorpic associations between my modes in the following way:
class User < ActiveRecord::Base has_many :items, :as => :agent class Item < ActiveRecord::Base belongs_to :agent, :polymorphic => true Agents can be users or clubs In the items controller I want to sort the agent column according to the name and surname of the agent (I know in advance that in this controller I will be displaying user agents), so per the API documentation I should do something like: config.columns[:agent].sort_by :sql => "concat(name, surname)" That of course doesn't work since it is not joining with the corresponding users table. I've tried also: config.columns[:agent].includes = [:user] But that doesn't work either because it joins with the correct table but it is not able to identify the join column properly (it looks for an user_id instead of agent_id in items table) My question is: how can I make the sort_by :sql work with this polymorphic association? Thanks in advance Pedro. -- 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.
