# Warning: already initialized constant TmpCert\_as\_text

**URL:** <https://www.ruby-forum.com/t/warning-already-initialized-constant-tmpcert-as-text/126499>\
**Category:** Ruby\
**Created:** [January 18, 2008, 7:27pm UTC](https://www.ruby-forum.com/t/warning-already-initialized-constant-tmpcert-as-text/126499 "2008-01-18T19:27:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![heinrich1208](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@heinrich1208](https://www.ruby-forum.com/u/heinrich1208)\
**Post date:** [January 18, 2008, 7:27pm UTC](https://www.ruby-forum.com/t/warning-already-initialized-constant-tmpcert-as-text/126499/1 "2008-01-18T19:27:27Z")

</div>

Hi all,

I use this in a ‘loop do’:

validationcheck = OpenSSL::X509::Certificate  
TmpCert\_as\_text = validationcheck.new(File.read(“certs.pem”)).to\_text

and I get this warning message:

warning: already initialized constant TmpCert\_as\_text

How can I get rid of it?

bye and thanks in advance  
Henry

---

<div class="post-metadata">

**Author:** ![heinrich1208](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@heinrich1208](https://www.ruby-forum.com/u/heinrich1208)\
**Post date:** [January 18, 2008, 8:06pm UTC](https://www.ruby-forum.com/t/warning-already-initialized-constant-tmpcert-as-text/126499/2 "2008-01-18T20:06:59Z")

</div>

Heinrich P. wrote:

> Hi all,
> 
> I use this in a ‘loop do’:
> 
> validationcheck = OpenSSL::X509::Certificate  
> TmpCert\_as\_text = validationcheck.new(File.read(“certs.pem”)).to\_text
> 
> and I get this warning message:
> 
> warning: already initialized constant TmpCert\_as\_text
> 
> How can I get rid of it?
> 
> bye and thanks in advance  
> Henry

Ruby treats a variable name that starts with an uppercase letter as a  
constant. Use tmpcert\_as\_text instead.

---

<div class="post-metadata">

**Author:** ![heinrich1208](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@heinrich1208](https://www.ruby-forum.com/u/heinrich1208)\
**Post date:** [January 18, 2008, 8:10pm UTC](https://www.ruby-forum.com/t/warning-already-initialized-constant-tmpcert-as-text/126499/3 "2008-01-18T20:10:08Z")

</div>

Tim H. wrote:

> Heinrich P. wrote:
> 
> > Hi all,
> > 
> > I use this in a ‘loop do’:
> > 
> > validationcheck = OpenSSL::X509::Certificate  
> > TmpCert\_as\_text = validationcheck.new(File.read(“certs.pem”)).to\_text
> > 
> > and I get this warning message:
> > 
> > warning: already initialized constant TmpCert\_as\_text
> > 
> > How can I get rid of it?
> > 
> > bye and thanks in advance  
> > Henry
> 
> Ruby treats a variable name that starts with an uppercase letter as a  
> constant. Use tmpcert\_as\_text instead.

Life is sometimes that easy - but you don’t recognize it 🙂

Thx.

Perfect!!!

bye  
Henry

---

<div class="post-metadata">

**Author:** ![heinrich1208](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@heinrich1208](https://www.ruby-forum.com/u/heinrich1208)\
**Post date:** [January 18, 2008, 8:14pm UTC](https://www.ruby-forum.com/t/warning-already-initialized-constant-tmpcert-as-text/126499/4 "2008-01-18T20:14:53Z")

</div>

In Ruby all variables that starts with capital letter are treated as  
constants. But Ruby just give you warning if you assign new value to  
constant. Just use small letters in variable names. In your case it  
would be: tmp\_cert\_as\_text. And don’t mix different styles for  
variable names. Ruby programmers prefer to use underscored\_names  
rather than camelNames.

–  
Rados³aw Bu³at

[http://radarek.jogger.pl](http://radarek.jogger.pl) - mój blog
