-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add ActiveRecord::Store Support #98
Conversation
I think this looks like a great start @jacobdaddario! 🙏 We'll have to add an example in the dummy app to test against. You're exactly right about how it works. We basically load the model, then poke around to find all the attributes (which includes columns and virtual attributes) and then filter out what we don't want to display. You set it up right because we want to generate fields for the store_accessors, but not the json column itself since you won't generally be editing the raw JSON. Let's add a column or model to the dummy app and a store_accessor or two. I don't have great tests for the resource generator yet. I mostly just run them in the dummy app and confirm it added the fields correctly right now. |
Awesome! Thanks for the super detailed response. It gives me great direction. I’ll get the tests going ASAP. I’ll shoot for this weekend at the latest. |
I've added some test data, but for some reason the dummy app is erroring on me. I'm getting an error mentioning that the attribute Any idea what's going on with this? |
Post the error and I'll take a look. |
…pp. Regenerated user and found issue with rendering.
Alright, a couple things:
I've corrected both of these bugs and regenerated the posts resource. Now after regenerating the users resource to test the accessors, a bug with representing the store has popped up. For now I've pushed my changes. I'll work on rooting the bug out another time. Shooting for this weekend at the latest. |
I worked on it a little more. Got everything working and then the test suite broke... Will investigate more when I have time. I'll also end up squashing all of these commits together. |
Edit: Shoot, the CI failed because the earlier versions of rails don't support the divided routes file... This is gonna be interesting to work out. Do you have any ideas on how to handle this? I'm not used to supporting multiple versions of Rails. Hey! I think this is meragble. When I regenerated the post and user resources, I accidentally overrode some custom behavior which has been re-implemented now. That said, there were some attributes on the post resource that don't seem to exist in the database anymore, so I removed them and edited a failing test that was dependent on them. I added a little bit to the resource class to get things functioning. I don't think we need tests for them since I don't see similar tests for changes like that in the code base, but if you feel we do I can go ahead and add some. Also, I can squash the commits down if you'd like. There was definitely some troubleshooting involved to get familiar with the test suite. Otherwise, I manually inspected the dummy app and the Store columns seem to be showing up correctly! |
This looks really good! I can squash when we merge this, so no worries there. I actually wrote a little helper method to check for the separated routes file for madmin: madmin/lib/madmin/generator_helpers.rb Line 39 in c1c5ba4
Good call on testing against JSON and text columns. 👍 We use that in the generators so they can check for the separate file and generate routes there. The dummy app probably needs to stick to the regular routes file for backwards compatibility and easier testing. Are the routes the last piece here? |
Looks like something else got caught by the CI too… Let me take a closer look and I’ll just ping you when I’m done so I don’t keep setting off GitHub notifications for you. |
I've addressed the things the CI kept complaining about. For some reason when I run database migrations, it keeps wanting to change |
I'm not sure why it writes them as |
Sweet, well I think this is done then so I won't add any more commits. Let me know if something needs changed still. |
This is a start of a PR to address #95. I'm not totally familiar with how Madmin works internally, so I think I just need to address this at the generator level. My understanding is after the Madmin class is generated, the super classing just shoves the generated attributes into the
attributes
class attribute using the attributes API. At least that's as far as I understood.Regardless, this still needs tests, so let me know if there's something I missed. I poked around a bit, but I was a bit time-pressured tonight.