I did solve the problem. First I tried:
def index
hobo_index Assignment.find(:all, :order => "due_date ASC" , :conditions =>
["show_date <= ?", Time.now])
end
which made some progress, since the select was executed on the database. But
now I got an error:
undefined method `scope' for #<Array:0x1055e62e8>
the top of the trace is:
/Library/Ruby/Gems/1.8/gems/hobo-1.0.1/lib/hobo/model_controller.rb:454:in
`send'
/Library/Ruby/Gems/1.8/gems/hobo-1.0.1/lib/hobo/model_controller.rb:454:in
`find_or_paginate'
/Library/Ruby/Gems/1.8/gems/hobo-1.0.1/lib/hobo/model_controller.rb:483:in
`hobo_index'
I looked in model_controller.rb and saw the line:
finder = args.first || model
and tried
def index
hobo_index(model,:conditions=>["show_date <= ?", Time.now], :order =>
"due_date ASC")
end
And this worked. Just wanted to document this example in case anyone follows
these threads. I know I do!
Thanks,
Mark
On Aug 30, 2010, at 10:58 PM, kevinpfromnm wrote:
> try hobo_index Assigment.find ... although I believe you can just pass
> it the finder options and the question is do you want pagination
> still?
>
> On Aug 30, 8:44 pm, Mark Sobkowicz <[email protected]> wrote:
>> I am trying to modify the controller action hobo_index in order to limit a
>> find. The hobo-at-work book has no examples, so I'm struggling to
>> understand "hobo_index takes a "finder" as an optional first argument, and
>> then options" . My find would be
>>
>> @assignments = Assignment.find(:all, :order => "due_date ASC" , :conditions
>> => ["show_date <= ?", Time.now])
>>
>> How can I write the hobo_index line to reflect this?
>>
>> ==========
>>
>> Reading the stuff on page 85 of hobo-at-work I also tried adding to the end
>> of AssignmentsController
>>
>> def index
>> @assignments = Assignment.find(:all, :order => "due_date ASC" ,
>> :conditions => ["show_date <= ?", Time.now])
>> end
>>
>> but I got
>>
>> NoMethodError in AssignmentsController#index
>>
>> undefined method `total_pages' for #<Array:0x10566dbd0>
>>
>> So I think the line on that page:
>>
>> "in other words you don't need to do anything different than you would in a
>> normal Rails action"
>>
>> is maybe not true. I assume its trying to paginate, which I don't want to
>> turn off - I'm all in favor of pagination.
>>
>> Thanks for all the help,
>>
>> Mark
>
> --
> 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.
>
--
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.