Broken localization: undefined method `gettext_translation_for_attribute_name'

Hello,
as I was updating the current devlop branch for foreman this morning the
following error appears whenever I edit a host, that's been connected to a
given ComputeResource.
The following error appears there:
ActionView::Template::Error (undefined method
gettext_translation_for_attribute_name' for Fog::Compute::Libvirt::Server:Class): 1: <% new = f.object && f.object.new? -%> 2: <%= text_f f, :name, :disabled => !new if controller_name != "hosts" %> 3: <%= selectable_f f, :cpus, 1..compute_resource.max_cpu_count, { }, :class => "input-mini",:disabled => !new %> 4: <%= selectable_f f, :memory, memory_options(compute_resource.max_memory), { }, :class => "span2", :disabled => !new %> 5: 6: <!--NICS--> app/helpers/layout_helper.rb:124:inblock in field'

The full trace can be seen here:
http://pastebin.com/fm89dEJq

I kind of fixed it as follows but I'm not sure if this is in anyways as
intended. Please point me what to do?

diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb
index 2773f90…5d189c9 100644
— a/app/helpers/layout_helper.rb
+++ b/app/helpers/layout_helper.rb
@@ -121,7 +121,7 @@ module LayoutHelper
help_inline = inline.blank? ? '' : content_tag(:span, inline, :class
=> "help-inline")
help_block = content_tag(:span, options.delete(:help_block), :class
=> "help-block")
content_tag :div, :class => "control-group #{fluid ? "row-fluid" : ""}
#{error.empty? ? "" : 'error'}" do

  •  label = options.delete(:label) || 
    

s_(f.object.class.gettext_translation_for_attribute_name attr)

  •  label = options.delete(:label) || ((f.object.class.respond_to? 
    

:gettext_translation_for_attribute_name) &&
s_(f.object.class.gettext_translation_for_at
label_tag(attr, label, :class=>"control-label").html_safe +
content_tag(:div, :class => "controls") do
yield.html_safe + help_inline.html_safe + help_block.html_safe

At least this patch makes the error go away :wink:

Regards Marc.

Marc,

your patch is correct - I did not count with non-model objects.

The method gettext_translation_for_attribute_name is added by rails i18n
gettext gem - it returns gettext translation for given column.

I will go ahead and create a issue/PR that fixes the error.

Thanks for reporting this and the fix.

LZ

··· On Thu, Apr 25, 2013 at 12:09:22AM -0700, Marc Grimme wrote: > Hello, > as I was updating the current devlop branch for foreman this morning the > following error appears whenever I edit a host, that's been connected to a > given ComputeResource. > The following error appears there: > ActionView::Template::Error (undefined method > `gettext_translation_for_attribute_name' for > Fog::Compute::Libvirt::Server:Class): > 1: <% new = f.object && f.object.new? -%> > 2: <%= text_f f, :name, :disabled => !new if controller_name != "hosts" > %> > 3: <%= selectable_f f, :cpus, 1..compute_resource.max_cpu_count, { }, > :class => "input-mini",:disabled => !new %> > 4: <%= selectable_f f, :memory, > memory_options(compute_resource.max_memory), { }, :class => "span2", > :disabled => !new %> > 5: > 6: > app/helpers/layout_helper.rb:124:in `block in field' > > The full trace can be seen here: > http://pastebin.com/fm89dEJq > > I kind of fixed it as follows but I'm not sure if this is in anyways as > intended. Please point me what to do? > > diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb > index 2773f90..5d189c9 100644 > --- a/app/helpers/layout_helper.rb > +++ b/app/helpers/layout_helper.rb > @@ -121,7 +121,7 @@ module LayoutHelper > help_inline = inline.blank? ? '' : content_tag(:span, inline, :class > => "help-inline") > help_block = content_tag(:span, options.delete(:help_block), :class > => "help-block") > content_tag :div, :class => "control-group #{fluid ? "row-fluid" : ""} > #{error.empty? ? "" : 'error'}" do > - label = options.delete(:label) || > s_(f.object.class.gettext_translation_for_attribute_name attr) > + label = options.delete(:label) || ((f.object.class.respond_to? > :gettext_translation_for_attribute_name) && > s_(f.object.class.gettext_translation_for_at > label_tag(attr, label, :class=>"control-label").html_safe + > content_tag(:div, :class => "controls") do > yield.html_safe + help_inline.html_safe + help_block.html_safe > > At least this patch makes the error go away ;-) > > Regards Marc. > > -- > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >


Later,

Lukas “lzap” Zapletal
irc: lzap #theforeman