Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Export maintains last filtered state #4611

Closed
stevepaulo opened this issue Sep 2, 2016 · 4 comments
Closed

CSV Export maintains last filtered state #4611

stevepaulo opened this issue Sep 2, 2016 · 4 comments

Comments

@stevepaulo
Copy link

If I filter the index page for a data model, the CSV Export link at the bottom appropriately exports only those records that match the filter. If I change the filter, then the Export link appropriately handles that, too.

But if I click "Clear Filters," the CSV Export link actually exports whatever records match the previous filter. Refreshing the page doesn't help, and I've looked for some kind of caching going on that could be the culprit, without success.

Am I missing something? Or is this a real bug?

@prasadsurase
Copy link
Contributor

@stevepaulo I wasn't able to reproduce the error. I am using ruby(2.2.2), rails(4.2.5.2) and activeadmin(1.0.0.pre2). Could you please post a sample repo demonstrating the said error?

@stevepaulo
Copy link
Author

Unfortunately I can't produce a repo as this is occurring in an internal tool. I have slightly different versions, but nothing major (ruby 2.2.1, rails 4.2.0, AA 1.0.0.pre)

@timoschilling
Copy link
Member

I’m going to close this since you haven’t responded. Please feel free to update this issue with additional information so it can be reconsidered.

@neilabdev
Copy link

In my case, I was using a manually integrated module to save ActiveAdmin filters when pages are changed... This way, when you click back to the model's page with filters, it would contain prior search data. Code was added to clear filters to erase the saved filters in the session, but was not working for CSV's because the regular model's index :key used in the session was slightly different ActiveAdmin's CSV link, because it included the :format, which prevented that key from ever being deleted. The link to the code is here:

https://gist.github.com/tinynumbers/5896537

The troublesome line was here:

def controller_key
        #params[:controller].gsub(/\//, '_').to_sym
        current_path = request.env['PATH_INFO']
        current_route = Rails.application.routes.recognize_path(current_path)
        current_route.sort.flatten.join('-').gsub(/\//, '_').to_sym # original line, BAD :( - produces :controller_model_index_csv
       "#{current_route[:controller]}/#{current_route[:action]}".gsub(/\//, '_').to_sym # produces :controller_model_index
      end

After applying the fix, it worked for me. Not an ActiveAdmin issue, but added here to help those that follow. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants