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

How to apply rails_admin for ActiveSupport::Concern used across multiple models? #2858

Open
marat-chardymov opened this issue Mar 23, 2017 · 1 comment

Comments

@marat-chardymov
Copy link

marat-chardymov commented Mar 23, 2017

I have concern like

module FollowableModelConcern extend ActiveSupport::Concern
  included do
    has_many :followers, -> { order :created_at }, class_name: 'User', through: :followings
    has_many :followings, as: :followable, dependent: :destroy
  end
end

It is included in several of my models. How can I exclude :followings field for example from edit action? I don't want to repeat exclude code for every model

@marat-chardymov
Copy link
Author

marat-chardymov commented Mar 24, 2017

Seems like I should use rails admin config inside included:

  included do
    has_many :followers, -> { order :created_at }, class_name: 'User', through: :followings
    has_many :followings, as: :followable, dependent: :destroy

    rails_admin do
      edit do
        exclude_fields :followings
      end
    end
  end

but when I include 2 concerns into my model, only one is applied. Probably it's because exclude_fields method rewrites exclude fields array...

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

1 participant