motor-admin / motor-admin-rails

Low-code Admin panel and Business intelligence Rails engine. No DSL - configurable from the UI. Rails Admin, Active Admin, Blazer modern alternative.
https://app.getmotoradmin.com/demo/
MIT License
767 stars 77 forks source link

Virtual attributes question #16

Closed drewbaumann closed 3 years ago

drewbaumann commented 3 years ago

Hello. We are using Lockbox to encrypt sensitive information. These fields are accessible in plaintext via virtual attributes. I'm sure that at some point we will be asked to expose those fields to admins using Motor Admin. Is this possible now or is it a planned feature?

Thank you!

omohokcoj commented 3 years ago

@drewbaumann, virtual attributes are supported in MotorAdmin. All you need to do is to just to add a new column so the column name matches the name of your virtual attribute (basically the AR model instance method).

You can check how it works in the demo app - so here we have a lifetime_value method (aka virtual attribute): https://github.com/omohokcoj/motor-admin/blob/master/spec/dummy/app/models/customer.rb#L27 And on the resource settings there is a 'Lifetime value' column added to the resource settings: image

Also it's possible to add a virtual column (field) to the create/update resource forms by specifying 'Read-Write' or 'Write-Only' visibility.

drewbaumann commented 3 years ago

@omohokcoj thank you. I must have totally glossed over that while reading the README. Thank you for your support! I've asked a couple questions now and you've been very helpful.