title: Rails : serialize Ruby range
body: <p>I'm running Rails 3.2.17 (also tried it with 3.2.22).
  I have trouble with serialization of a ruby Range in my model:</p>
  
  <pre><code>class MyModel &lt; ActiveRecord::Base
    attr_accessible :my_column
    serialize :my_column, Range
  end
  </code></pre>
  
  <p>When I try to create an record like this:</p>
  
  <pre><code>MyModel.create()
  # Or like this
  MyModel.create({my_column: (0..2)})
  </code></pre>
  
  <p>I have this error:</p>
  
  <pre><code>ArgumentError: wrong number of arguments (0 for 2..3)
  </code></pre>
  
  <p>How can I solve this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have found a way like this:</p>
  
  <pre><code>class MyModel &lt; ActiveRecord::Base
    attr_accessible :my_column
    # NO MORE SERIALIZE
  
    def my_column=(val)
      self[:my_column] = YAML.dump(val)
    end
  
    def my_column
      YAML.load(super || YAML.dump(nil))
    end
  end
  </code></pre>