When do we nest class?


#1

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?