On Dec 13, 2009, at 10:11 AM, Jelte Liebrand wrote: > Not sure this is the right forum for feedback, but I've just been > trying out hobo as somewhat of a newbie. This book is great, but one > thing I've noticed is that the section "Writing an action from > scratch" implies you can just create your own index action by > setting the @adverts to something. > > I am not using the publish named scope thing, but using > find_all_by_title on my model instead, and this gives me an error: > undefined method `total_pages' for #<Array:0x105a04f28> > > It would appear that you can not *just* set the array, as it needs > to be a paginated array (I'm guessing here?) > > I figured perhaps i should not re-write the index action, but > instead extend it. Using the hobo_index call, things start to work, > but all items are shown again. I can not override what array it > uses, not even if i use the hobo_index do block (i was just guessing > there). So I *guess* one should not extend the hobo_index ? >
The trick is that hobo_index also takes parameters - in particular, the collection to show. So this should work: def index hobo_index Advert.find_all_by_title(...) end or, if you want pagination to work, use a scope: def index hobo_index Advert.name_is(...) end The index action doesn't seem like the best example, as the default generated index-page tag makes some assumptions about the collection that ends up in 'this'. If you want that to behave better, make sure to turn off pagination in the view hints: class AdvertVIewHints < Hobo::ViewHints paginate false end which will make the page-nav links vanish. > All in all it is rather difficult to understand exactly what hobo is > or is not expecting. I guess this ties in to the "too much magic" > comment elsewhere in the book. But at the moment I do not know how > to change the default index action > Appreciate the feedback - it's hard to notice the little blind alleys in the documentation once you've used Hobo for a year or so... :) --Matt Jones -- 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.
