Project

General

Profile

Bug #5679

Using compute_resource_name in API results in undefined method `find_by_to_label'

Added by Dominic Cleal almost 9 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

Description

Trying to identify a compute resource by name with the "compute_resource_name" helper throws the following error:

Started POST "/api/v2/hosts" for 127.0.0.1 at 2014-05-12 16:07:23 +0100
Processing by Api::V2::HostsController#create as JSON
  Parameters: {"name"=>"test4250", "hostgroup_name"=>"libvirt", "compute_resource_name"=>"localhost", "compute_profile_name"=>"libvirt", "apiv"=>"v2", "host"=>{"name"=>"test4250", "hostgroup_name"=>"libvirt", "compute_resource_name"=>"localhost", "compute_profile_name"=>"libvirt"}}
undefined method `find_by_to_label' for #<Class:0x007fba0fe099a0> (NoMethodError)
/home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.18/lib/active_record/dynamic_matchers.rb:27:in `method_missing'
/home/dcleal/code/foreman/foreman/app/models/concerns/has_many_common.rb:83:in `block in belongs_to_name_for'
/home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.18/lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
/home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.18/lib/active_record/attribute_assignment.rb:78:in `each'
/home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.18/lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
/home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/activerecord-3.2.18/lib/active_record/base.rb:498:in `initialize'
/home/dcleal/.rvm/gems/ruby-2.0.0-p247@foreman/gems/actionpack-3.2.18/lib/action_dispatch/routing/url_for.rb:103:in `initialize'
/home/dcleal/code/foreman/foreman/app/models/concerns/foreman/sti.rb:22:in `new'
/home/dcleal/code/foreman/foreman/app/models/concerns/foreman/sti.rb:22:in `new_with_cast'
/home/dcleal/code/foreman/foreman/app/models/host.rb:16:in `method_missing'
/home/dcleal/code/foreman/foreman/app/controllers/api/v2/hosts_controller.rb:70:in `create'

Associated revisions

Revision 6a6cccfe (diff)
Added by Dominic Cleal over 8 years ago

fixes #5679 - change CR identifier to name to fix has_many association lookup

History

#1 Updated by Dominic Cleal almost 9 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal
  • Target version set to 1.8.1

#2 Updated by Dominic Cleal almost 9 years ago

  • Status changed from Assigned to Ready For Testing

#3 Updated by Dominic Cleal over 8 years ago

  • Legacy Backlogs Release (now unused) set to 10

#4 Updated by Dominic Cleal over 8 years ago

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

Also available in: Atom PDF