Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rendering paginated_collection in #show block reveals bug #412

Closed
samvincent opened this Issue · 6 comments

3 participants

@samvincent

When rendering a table of a resources associated entries within the show context, The collection var in ActiveAdmin::Views::PaginatedCollection#page_entries_info is the main resource and not the passed collection.

show do
  collection = resource.items
  paginated_collection(collection) do
    table_for collection, {:sortable => true, :class => "index_table", :i18n => LineItem}
  end
end

There are no unit specs for PaginatedCollection and the style differs a bit from the other components I looked at (TableFor works as expected). Would you be able to enlighten me a little bit on why the collection I passed in isn't being respected so I can put a patch together?

The other thing is that there's no option to remove the download format links which aren't wanted here. They currently link to the show actions resource as well.

I'd like to write some specs for these two features, but I need to understand a little more about why rendering the paginated_collection within the show context is producing these results. Any help is much appreciated.

@gregbell
Owner

Hi Sam!

This is actually a great find. The issue is in the #page_entries_info method. It calls the method #collection which is actually a helper provided by Active Admin to get the collection on the index page. Instead, that method should use the value set in @collection.

I think the simplest solution is to add some specs to that method and then an attr_reader :collection. If you've got the time to fork, branch and implement I'll pull it and release it in 0.3.1.

Thanks!

@samvincent samvincent closed this
@samvincent samvincent referenced this issue from a commit in samvincent/active_admin
@samvincent samvincent Issue #412 - Fix scope issue with :collection for PaginatedCollection…
… component

When rendering a PaginatedCollection for an associated collection within the
show context (for example), the :collection method called was referring to the resource
rather than the passed in collection. Also raising error if collection has not been
scoped with Kaminari to help new users figure it out.
c6813b5
@samvincent samvincent referenced this issue from a commit in samvincent/active_admin
@samvincent samvincent Issue #412 - Added support for :param_name to PaginatedCollection
Setting :param_name allows you to put multiple paginated collections
on a single page. (eg. Show action)
1d3895a
@samvincent samvincent referenced this issue from a commit in samvincent/active_admin
@samvincent samvincent Issue #412 - Disable download links option for PaginatedCollection
When rendering a paginated collection on the show screen for example,
it does not make sense to include resource download links for the collection.
2043acb
@samvincent samvincent reopened this
@samvincent

I have no idea how this closed it self. I've made some commits for the options I need. Commit messages explain why I need them. Making a pull request now.

@samvincent samvincent referenced this issue from a commit in samvincent/active_admin
@samvincent samvincent Issue #412 - Fix for broken cuke complaining of unsymbolized key 3027431
@dawidw

was this fix finally released in 0.3.1? because i'm still having this issue in 0.3.2.

@samvincent

Hasn't been merged yet. I've forked the project and have been merging in various fixes for my production active admin. You can merge in my branch that fixes this if you need it right away.

@dawidw

not in a hurry, just curious ; )

@simi simi referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@simi simi referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@simi simi referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@simi simi referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@samvincent

Closing as this has been merged in pull req #428

@samvincent samvincent closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.