# When do we nest class?

**URL:** <https://www.ruby-forum.com/t/when-do-we-nest-class/151885>\
**Category:** Rails\
**Created:** [October 27, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/when-do-we-nest-class/151885 "2008-10-27T15:34:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubyernewbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@rubyernewbie](https://www.ruby-forum.com/u/rubyernewbie)\
**Post date:** [October 27, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/when-do-we-nest-class/151885/1 "2008-10-27T15:34:49Z")

</div>

class Sidebar \< ActiveRecord::Base  
serialize :config

class Field  
attr\_accessor :key  
attr\_accessor :options  
attr\_accessor :default  
include ApplicationHelper  
include ActionView::Helpers::TagHelper  
include ActionView::Helpers::FormTagHelper  
include ActionView::Helpers::FormOptionsHelper

```
def initialize(key, default, options = { })
  @key, @default, @options = key.to_s, default, options
end

class SelectField < self
  def input_html(sidebar)
    select_tag(input_name(sidebar),
               options_for_select(options[:choices],

```

sidebar.config[key]),  
options)  
end  
end

```
class TextAreaField < self
  def input_html(sidebar)
    html_options = { "rows" => "10", "cols" => "30", "style" =>

```

“width:255px”}.update(options.stringify\_keys)  
text\_area\_tag(input\_name(sidebar), h(sidebar.config[key]),  
html\_options)  
end  
end

end

==  
some code on typo

My silly question is when do we need nest class?  
the nested class good for?
