<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>60401</bug_id>
          
          <creation_ts>2026-09-04 17:46:13 +0300</creation_ts>
          <short_desc>alias_attribute :to_s, :to_label ломает работу моделей на Rails 7.1</short_desc>
          <delta_ts>2026-09-04 17:46:33 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>foreman</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugzilla.altlinux.org/show_bug.cgi?id=60396</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vladislav Glinkin">glinkinvd</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>admsasha</cc>
    
    <cc>cas</cc>
    
    <cc>majioa</cc>
    
    <cc>mike</cc>
    
    <cc>nbr</cc>
    
    <cc>pav</cc>
    
    <cc>placeholder</cc>
    
    <cc>rider</cc>
    
    <cc>thatman</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>295481</commentid>
    <comment_count>0</comment_count>
    <who name="Vladislav Glinkin">glinkinvd</who>
    <bug_when>2026-09-04 17:46:13 +0300</bug_when>
    <thetext>Версия пакета: foreman-3.19.1-alt1.2

---

Описание:
В /usr/lib/foreman/app/models/application_record.rb используется:
alias_attribute :to_s, :to_label

При этом to_label является методом, а не ActiveRecord-атрибутом.

В Rails 7.1 такое использование alias_attribute deprecated. Rails предупреждает, что начиная с Rails 7.2 alias_attribute с non-attribute target будет ошибкой и рекомендует использовать alias_method либо обычный метод.

https://guides.rubyonrails.org/7_1_release_notes.html#active-record-deprecations

---

На текущем стеке это уже приводит к неправильной работе:
```
cd /var/lib/foreman

RAILS_ENV=production bundle exec ruby -e &apos;
require &quot;./config/environment&quot;
Foreman.setup_console

d = Domain.unscoped.first
puts &quot;name=#{d.name.inspect}&quot;
puts &quot;to_label=#{d.to_label.inspect}&quot;
puts &quot;to_s=#{d.to_s.inspect}&quot;
puts &quot;owner=#{d.method(:to_s).owner}&quot;
&apos;
```

---

Результат:
name=&quot;test.domain.ru&quot;
to_label=&quot;test.domain.ru&quot;
to_s=nil
owner=ApplicationRecord::GeneratedAttributeMethods

Из-за этого при построении FQDN получается:
puppet-client.#&lt;Domain:0x...&gt;

вместо:
puppet-client.test.domain.ru

и Host не проходит валидацию имени.

Также эта проблема приводит к ошибкам отображения Host/API.

---

Исправление:
--- a/usr/lib/foreman/app/models/application_record.rb
+++ b/usr/lib/foreman/app/models/application_record.rb  
@@ -48,7 +48,9 @@ class ApplicationRecord &lt; ActiveRecord::Base  
    &quot;#{id}-#{self.class.table_name.humanize}&quot;  
  end  
  alias_attribute :to_label, :name_method  
-  alias_attribute :to_s, :to_label  
+  def to_s  
+    to_label  
+  end  
   
  def self.virtual_column_scope(name, proc)  
    name = name.to_sym

После исправления:
Domain#to_s=&quot;test.domain.ru&quot;
fqdn=&quot;puppet-client.test.domain.ru&quot;
Host validation=успешно
Host UI/API=работает</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>