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
new vs build for associations #132
Comments
Actually, it's related to assigning attributes separate from the initialisation of the object. In Rails 4, the change above will initialise the object as its correct subclass based on the params[:model][:type] passed in, but it has to be done when the object is initialised. I'll try to make a replacement strategy for this issue. Is it worth looking at making initialisation and attribute assignment in one step for |
I've had a go at this modification: #133 All tests pass (a couple had to be adjusted). Let me know what you think. |
Closing post as v3.0 is a different codebase |
I notice |
@brendon Are you having an issue then? |
Sorry no, not that I can see. I was just posting that there in case anyone else found the issue. |
I'm currently having a bit of a problem with a STI model.
I'm replacing existing working code to use
decent_exposure
and the only difference I can see in the code generated is thatdecent_exposure
usesnew
instead ofbuild
to set up the new record from the parent association. I think this might be affecting how the STI code creates the object as now Rails is ignoring any validations on the STI's particular type model and is only running the validations on the parent model.I was wondering what the reason was for using
new
instead ofbuild
in this case. Is it becausebuild
is sometimes unavailable?I've really enjoyed implementing
decent_exposure
overall. It definitely clarifies the code and I can get rid of all those nasty before_actions!The text was updated successfully, but these errors were encountered: