# DatePickerCtrl uninitialized constant

**URL:** <https://www.ruby-forum.com/t/datepickerctrl-uninitialized-constant/178533>\
**Category:** wxRuby\
**Created:** [November 6, 2009, 3:37am UTC](https://www.ruby-forum.com/t/datepickerctrl-uninitialized-constant/178533 "2009-11-06T03:37:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [November 6, 2009, 3:37am UTC](https://www.ruby-forum.com/t/datepickerctrl-uninitialized-constant/178533/1 "2009-11-06T03:37:46Z")

</div>

I trying to make a Dialog that include a DatePickerCtrl on my gentoo  
linux box.

I get the following error  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active\_support/dependencies.rb:478:in  
`const\_missing’: uninitialized constant PortfolioDialog::DatePickerCtrl  
(NameError)

My application use ActiveRecord, thats why the error is from  
activesupport.

gem list says  
wxruby (1.9.9, 1.9.8)

Should DatePickerCtrl work in this version?

---

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [November 6, 2009, 8:41am UTC](https://www.ruby-forum.com/t/datepickerctrl-uninitialized-constant/178533/2 "2009-11-06T08:41:32Z")

</div>

Hello Svend,

2009/11/5 Svend Haugaard SÃ¸rensen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> activesupport.
> 
> gem list says  
> wxruby (1.9.9, 1.9.8)

1.9.8 and 1.9.9 are old versions, you should use 2.0.1, as it is the  
newest,  
however the wxDatePickerCtrl is in 1.9.9 and 1.9.8. The problem is, is  
that  
ActiveSupport is trying to check for a Constant, that does not exist.  
You  
need to use Wx::DatePickerCtrl in order to make it work, unless you  
include  
Wx in PortfolioDialog class.

EG:

class PortfolioDialog \< Wx::Dialog  
def initialize  
super  
@dpc = Wx::DatePickerCtrl.new  
end  
end

Or:

class PortfolioDialog \< Wx::Dialog  
include Wx  
def initialize  
super  
@dpc = DatePickerCtrl.new  
end  
end

Or

module Wx  
class PortfolioDialog \< Dialog  
def initialize  
super  
@dpc = DatePickerCtrl.new  
end  
end  
end

The last method I would not use, as that pollutes the Wx namespace. But  
the  
point being, that when you subclass from a wxRuby class, it does not  
automatically inherit the Wx namespace. You need to either explicitly  
define it, include it, or define your class under the Wx namespace, in  
order  
to avoid having to use the Wx namespace in pre-pending of class  
definitions.

hth,

Mario

---

<div class="post-metadata">

**Author:** ![Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@Svend\_Haugaard\_SSSS](https://www.ruby-forum.com/u/Svend_Haugaard_SSSS)\
**Post date:** [November 6, 2009, 11:10am UTC](https://www.ruby-forum.com/t/datepickerctrl-uninitialized-constant/178533/3 "2009-11-06T11:10:11Z")

</div>

On Fri, 6 Nov 2009 02:40:47 -0500  
Mario S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > `const\_missing’: uninitialized constant  
> > newest, however the wxDatePickerCtrl is in 1.9.9 and 1.9.8. The  
> > problem is, is that ActiveSupport is trying to check for a Constant,  
> > that does not exist. You need to use Wx::DatePickerCtrl in order to  
> > make it work, unless you include Wx in PortfolioDialog class.

I have have a ‘include Wx’ just after ‘require “wx”’ in my program.

If I use @buy\_date=Wx::DatePickerCtrl.new(self,-1)  
the error change to

/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active\_support/dependencies.rb:263:in  
`load\_missing\_constant’: uninitialized constant Wxruby2::DatePickerCtrl  
(NameError)

I tried to make a ‘gem update wxruby’ and that installed the 1.9.9  
version. And it didn’t remove the error.
