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

Index page filtering ignores the current scope #3665

Open
mattruzicka opened this issue Jan 4, 2024 · 0 comments
Open

Index page filtering ignores the current scope #3665

mattruzicka opened this issue Jan 4, 2024 · 0 comments

Comments

@mattruzicka
Copy link

In rails_admin version 3.1.2, when a model is configured to have tabbed scopes on the index page and you do a filter search, the results are always scoped to the first tab and not the current scope/tab as expected.

Reproduction steps

I updated the active_record dummy app Ball model to have scopes like this:

# frozen_string_literal: true

class Ball < ActiveRecord::Base
  has_one :comment, as: :commentable

  validates_presence_of :color, on: :create

  scope :red, -> { where(color: 'red') }
  scope :green, -> { where(color: 'green') }
  scope :blue, -> { where(color: 'blue') }

  def to_param
    color.present? ? color.downcase.tr(' ', '-') : id
  end

  rails_admin do
    list do
      scopes [:red, :green, :blue]
    end
  end
end

Here you can see that I'm on the "Blue" scope tab and added a filter to only show balls of type "Basketball".

Screenshot 2024-01-04 at 11 02 44 AM

After clicking refresh, I expect the page to stay on the "Blue" tab and show only basketballs, but instead, it updates to only show basketballs for the default scope which is "Red".

Screenshot 2024-01-04 at 11 02 54 AM

If I then click on the blue tab, I see the results that I expected, but having to do that is an extra step and breaks the expectations set by previous versions.

Additional context

  • rails version: 6.1.7.6
  • rails_admin version: 3.1.2

I'm updating from rails_admin version 2.2.1, so I know that scopes and filters behaved as expected in at least that version.

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

No branches or pull requests

2 participants