Project

General

Profile

Refactor #13440

Replace Host::Base#model_name to prevent Rails 4.2 conflict

Added by Dominic Cleal over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Rails 4.2 implements #model_name in ActiveRecord::Base as an instance method rather than a class method (in 4.1 and older), changed in https://github.com/rails/rails/commit/6b0e834.

Our HasManyCommon concern adds a model_name method to Host::Base as an extension of the model/model_id association to the Model er, model. This will need to be removed to ensure the AR method continues to work.

When our model is in place, links to hosts can't be generated in Rails 4.2 as they return nil or string values from our implementation Host::Base#model_name rather than the ActiveModel::Name object expected.


Related issues

Related to Discovery - Bug #14227: Discovery mailer fails for hosts without model nameClosed2016-03-16
Related to Discovery - Refactor #14236: Rename model_name to hardware_model_nameDuplicate2016-03-16
Blocks Foreman - Feature #13244: Upgrade Ruby on Rails to 4.2Closed2016-01-15

Associated revisions

Revision 7c671609 (diff)
Added by Dominic Cleal over 3 years ago

fixes #13440 - rename Host#model_name to #hardware_model_name

Rails 4.2 defines a model_name instance method which is used in routing
and called from link_to. Rename our model_name methods to
hardware_model_name to prevent this overlapping and causing link_to
failures.

Host#hardware_model_name is provided as an equivalent getter to replace
it, and the #model_name= getter/setters are provided but are deprecated.
The deprecation period has been brought forward one release from the
usual, so as not to block an upgrade to Rails 4.2.

History

#1 Updated by Dominic Cleal over 3 years ago

#2 Updated by The Foreman Bot over 3 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3133 added

#3 Updated by Dominic Cleal over 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Dominic Cleal over 3 years ago

  • Legacy Backlogs Release (now unused) set to 71

#5 Updated by Dominic Cleal over 3 years ago

  • Related to Bug #14227: Discovery mailer fails for hosts without model name added

#6 Updated by Lukas Zapletal over 3 years ago

  • Related to Refactor #14236: Rename model_name to hardware_model_name added

Also available in: Atom PDF