THx for the help! I've solved it in the following way:
1) Appended to User model
has_one :most_recent_status, :class_name => 'Status', :order =>
"created_at desc"
2) In users_controller wrote:
def index
hobo_index do |wants|
wants.xml {
render :xml => @users.to_xml ( :include =>
[:most_recent_status, :messages ])
}
wants.html { }
end
end
On Jul 2, 6:01 pm, Bryan Larsen <[email protected]> wrote:
> hobo_index doesn't do very much -- just the find, along with pagination,
> and a basic render if you don't supply the block. So once you start
> doing things too different, it's often easier just to write your own
> controller action. Assigning to self.this will establish the initial
> context for DRYML.
>
> But in your case, you certainly can continue to use hobo_index by
> passing finder options to hobo_index, you'd want to pass :order_by =>
> "updated_at DESC", :limit => 1. (warning: options came from top of head)
>
> It does seem strange to me that you want your index action to only
> display a single value.
>
> Bryan
>
> Edward Samokhvalov wrote:
> > Hi All!
>
> > I have a little bit of a problem here with the customization of
> > my :include.
> > There are 3 tables: users, statuses and messages. Users have many
> > statuses and messages.
> > I had to get xml with all users, each having nested messages and
> > statuses linked by id.
>
> > That thing works
> > def index
> > hobo_index do |wants|
> > wants.xml {
> > render :xml => ( @users.to_xml :include =>
> > [:statuses, :messages])
> > }
> > wants.html { }
> > end
> > end
>
> > But now I need to take only the last record (that has most recent
> > timestamp) from statuses belonging to parent user, but I can't figure
> > out how to pass that parameter to hobo...
>
> > Thanks very much in advance!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---