Actions
Bug #5679
closedUsing compute_resource_name in API results in undefined method `find_by_to_label'
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'
Actions