def store_model_attributes(options)
file = options[:to] || 'locale/model_attributes.rb'
begin
File.open(file,'w') do |f|
f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!"
ModelAttributesFinder.new.find(options).each do |table_name,column_names|
model = table_name_to_namespaced_model(table_name)
if model == nil
puts "[Warning] Model not found for table '#{table_name}'"
next
end
f.puts("_('#{model.human_name_without_translation}')")
column_names.each do |attribute|
translation = model.gettext_translation_for_attribute_name(attribute)
f.puts("_('#{translation}')")
end
end
f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!"
end
rescue
puts "[Error] Attribute extraction failed. Removing incomplete file (#{file})"
File.delete(file)
raise
end
end