-
Notifications
You must be signed in to change notification settings - Fork 46
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
Introduce Scaffolding::Attribute
#124
Conversation
has_one
scaffolderScaffolding::Attribute
I decided to mark the PR here as ready for the following reasons
|
@gazayas This looks awesome! Can you resolve the conflicts and then I'll merge it? |
@andrewculver Done! |
@gazayas Looks like new conflicts have cropped up. I'd be happy to merge this once they're resolved. |
@gazayas ping (Sorry to ping you again, I'm just guessing this one fell through the cracks since you've been all over other PRs that I've asked about.) |
Hey @jagthedrummer, I definitely have this one on my radar, it'll just take some careful incision to make sure it works properly so I've been prioritizing the other PRs like CI test failure-related ones. Will ping you when I make some progress! |
OK, that sounds great! Sorry to be a pest. |
You're good 😃 |
@jagthedrummer Working on this one, having a hard time though because the super scaffolding tests are passing locally but not on CI for some reason. I know a lot has happened in CI so I hope it's not that, but I'll see what I can do. |
@jagthedrummer Done! That one had my head spinning 😵💫 |
@gazayas I'm so sorry I didn't merge this immediately last week, but now we have yet another conflict. 🤦 |
@jagthedrummer Conflicts resolved! Linking #109 since it was the one that had an affect on the latest merge. However, the Super Scaffolding partial tests are failing, and it's failing for me locally too on |
Note to self: The partial tests are working in isolation, but fail when running the entire test setup script. |
@jagthedrummer Done!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
🥳 😭 |
Purpose
The purpose of this PR is to set up
bullet_train-super_scaffolding
to implement ahas_one
scaffolder smoothly.(The issue to create a
has_one scaffolder
→ bullet-train-co/bullet_train#76)Classes to implement
For this to happen, I think it would benefit us to extract some logic from the Transformer and pinpoint where and how we want to build our association lines, the reason being that we Super Scaffold different types of associations to our models based on the attributes passed to
bin/super-scaffold
. I think where we build the line to eventually place in a model is an important design decision if we want to handle different types of associations dynamically, and I'm hoping to prevent some clutter by adding a couple of new classes.I propose the following classes:
Scaffolding::Attribute
Scaffolding::AssociationLineBuilder
Scaffolding::Attribute
As you can see with the first commit I've already added this, and there are a lot of diffs in the Transformer by changing
name
toattribute.name
, etc. Although this is technically longer, I was able to cut a lot of the attribute setup at the beginning of theadd_attributes_to_various_views
method which I believe makes the code much easier to read. I also think the intent is clearer by using this class so whoever reads our code knows thatattribute
is the key part of this method.Besides that, we can isolate a lot of the attribute-related logic here. What I'm specifically thinking of is how we declare associations. I was originally thinking of adding a class called
Scaffolding::Association
or a module namedScaffolding::Association::Helper
, but the more I thought about it,Scaffolding::Attribute
made the most sense because we don't know if an attribute is technically going to be an association to begin with.If we can manage association declaration here, I think it will be easier to set up the
has_one
scaffolder when we get there.Scaffolding::AssociationLineBuilder
I feel like a lot of this logic will naturally be repeated when we write
has_many
orbelongs_to
lines when Super Scaffolding. I haven't quite fleshed this class out yet, but my plan is to work on this next and cut the PR there. Then we could work with these two classes to implement thehas_one
scaffolder.