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

Fixes #11767 - set interface[:id] to nil only if it exists #2711

Closed
wants to merge 1 commit into from

Conversation

shlomizadok
Copy link
Member

Not sure why attributes[:interfaces_attributes][:id] = nil is needed in the first place though

@@ -729,7 +729,7 @@ def clean_interfaces_attributes
attributes = params[:host].dup
if params[:host][:interfaces_attributes]
attributes[:interfaces_attributes] = params[:host][:interfaces_attributes].dup.except(:created_at, :updated_at, :attrs)
attributes[:interfaces_attributes][:id] = nil
attributes[:interfaces_attributes][:id] = nil if attributes[:interfaces_attributes][:id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be fine to add this above as .dup.except(:id, :created_at, :updated_at, :attrs)

@dLobatog
Copy link
Member

@shlomizadok Thanks! Can you add a test to make sure we don't get any regressions in this area?

@ares
Copy link
Member

ares commented Sep 14, 2015

This patch would help fix mass assignment exception but wouldn't with resolving the templates. IDs of nested interfaces are still present so when you add new interface and resolve a template, we'd get
not found: Couldn't find Nic::Base with ID=2784 for Host::Managed with ID= because we don't load existing host but build a new one. See 8405 and 9058 for better context. I'll try to look at it.

@ares
Copy link
Member

ares commented Sep 14, 2015

For an alternative fix see #2713

@shlomizadok
Copy link
Member Author

Closing in favor of #2713, which seems to cover this better. Thanks @ares

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants