I just copied this out of a auto/rapid/pages.dryml index page minus
the param statements so YMMV
<page-nav />
<collection:pcap_sessions.paginate_this />
<page-nav />
In addition to that, you'll have grab the right records for the
collection, either in the controller or at the collection call. At
very least you'll need to get the page number from the parameters. In
controller show method:
hobo_show
@page = param[:page] || 1
@pcap_sessions = this.pcap_sessions.paginate_code_or_scope(@page)
#add pagination
<collection:pcap_sessions.paginate_code_or_scope(@page) />
or <collection with="&@pcap_sessions" /> if you grabbed the records
in the controller.
Hopefully that wasn't too chaotic to follow. Don't know if there's
already a scope or method to handle pagination added by hobo (seems
like there would be).
On Feb 11, 5:17 am, Patrick Fitzgerald <[email protected]> wrote:
> Hi All,
> Confused at the moment. I am using the standard Hobo output to
> display results. The model: capture_profile has many children
> pcap_sessions. In one case there are 800+ children. These are all
> being displayed on the page. Each card only shows two lines. This
> is having a performance impact. I have optimized the database queries
> using eager loading to avoid the N+1 issue. Here's a sample of the
> output in the log:
>
> Processing CaptureProfilesController#show (for 000.000.000.000 at
> 2010-02-11 12:13:22) [GET]
> Parameters: {"id"=>"2-2010-02-08-00-26-47"}
> Completed in 22705ms (View: 22162, DB: 3) | 200 OK
> [http://testsite/capture_profiles/2-2010-02-08-00-26-47]
>
> Environment:
> Linux (Debian)
> Apache2
> Production Rails environment.
>
> As you can see the database query is taking 3ms but the building of
> the 800+ cards for the view is taking 22162ms to complete. One way
> around this is to use pagination. The pagination works when I view the
> pcap_sessions directly. But when they are viewed as a child of another
> model I run into this problem. As yet I haven't been able to force
> pagination. Can someone tell me how to enable pagination in this
> case. This is what the code looks like in my application.dryml:
>
> <def tag="show-page" for="CaptureProfile">
> <page merge title="#{ht 'capture_profiles.show.title',
> :default=>['Capture Profile'] }">
>
> <body: class="show-page capture profile" param/>
>
> <content: param>
> <section-group>
> <section param="main-content">
> <header param="content-header">
> <h2 param="heading">
> <ht
> key="capture_profiles.show.heading" name="&this.respond_to?(:name) ?
> this.name : ''">
> <name/>
> </ht>
> </h2>
>
> <record-flags fields=""
> param/>
>
> <a action="edit"
> if="&can_edit?" param="edit-link">
> <ht
> key="capture_profiles.actions.edit" name="&this.respond_to?(:name) ?
> this.name : ''">
> Edit
> Capture Profile
> </ht>
> </a>
> </header>
>
> <section param="content-body"
> with-flash-messages>
> <section
> param="collection-section">
> <h3
> param="collection-heading">
> <ht
> key="capture_profiles.collection.heading.other" >
>
> Pcap Sessions
> </ht>
> </h3>
>
> ### THIS IS
> WHERE I NEED TO ENABLE PAGINATION###
>
> <collection:pcap_sessions />
>
> </section>
> </section>
> </section>
>
> </section-group>
> </content:>
> </page>
> </def>
--
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.