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

Made changes to code to only access name if record exists. #946

Conversation

h-kataria
Copy link
Contributor

Ansible objects selected when adding Catalog Item could have been deleted from database so need to check for their existence before accessing their names to be displayed on summary screen.

https://bugzilla.redhat.com/show_bug.cgi?id=1439144

@gmcculloug @bzwei please test

end
end
playbook_details
end

def fetch_name_from_object(klass, id)
item = klass.find_by(:id => id)
item ? item.name : nil
Copy link
Member

Choose a reason for hiding this comment

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

Replace these with: klass.find_by(:id => id).try(:name)

Ansible objects selected when adding Catalog Item could have been deleted from database so need to check for their existence before accessing their names to be displayed on summary screen.

https://bugzilla.redhat.com/show_bug.cgi?id=1439144
@h-kataria h-kataria force-pushed the access_record_attributes_if_record_exists branch from 2154544 to 98c0cde Compare April 6, 2017 17:05
@miq-bot
Copy link
Member

miq-bot commented Apr 6, 2017

Checked commit h-kataria@98c0cde with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks good. 🍪

@h-kataria
Copy link
Contributor Author

@gmcculloug made suggested change.

@dclarizio dclarizio merged commit c1d9f9f into ManageIQ:master Apr 6, 2017
@dclarizio dclarizio added this to the Sprint 58 Ending Apr 10, 2017 milestone Apr 6, 2017
simaishi pushed a commit that referenced this pull request Apr 6, 2017
…cord_exists

Made changes to code to only access name if record exists.
(cherry picked from commit c1d9f9f)

https://bugzilla.redhat.com/show_bug.cgi?id=1439948
@simaishi
Copy link
Contributor

simaishi commented Apr 6, 2017

Fine backport details:

$ git log -1
commit ed99e3e2f2838ae60a342c5688ba71e95a661101
Author: Dan Clarizio <[email protected]>
Date:   Thu Apr 6 10:28:06 2017 -0700

    Merge pull request #946 from h-kataria/access_record_attributes_if_record_exists
    
    Made changes to code to only access name if record exists.
    (cherry picked from commit c1d9f9fd0cd8afe4e0c001729a62324f9d56b78d)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1439948

@h-kataria h-kataria deleted the access_record_attributes_if_record_exists branch April 27, 2017 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants