# About active record read and write attributes

**URL:** <https://www.ruby-forum.com/t/about-active-record-read-and-write-attributes/146622>\
**Category:** Rails\
**Created:** [August 23, 2008, 4:56am UTC](https://www.ruby-forum.com/t/about-active-record-read-and-write-attributes/146622 "2008-08-23T04:56:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [August 23, 2008, 4:56am UTC](https://www.ruby-forum.com/t/about-active-record-read-and-write-attributes/146622/1 "2008-08-23T04:56:27Z")

</div>

I have read the rails documents about the active record read and write  
attributes.They says reading attributes have typecast automaticly  
running behind.  
But i wonder if this typecast works even the active record object has  
not yet been saved to the database when reading attributes.  
As for writing attributes,is there the typecast works behind even the  
active record object has not yet been saved to the database?  
If the controller receives the form data from user to construct an  
active record object,all the params are string,should i manually cast  
these strings to the corresponding type in the schema before making an  
active record object and saving it? The automatic typecast works behind?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [August 23, 2008, 8:18am UTC](https://www.ruby-forum.com/t/about-active-record-read-and-write-attributes/146622/2 "2008-08-23T08:18:52Z")

</div>

All the incoming params submitted from form have the string type value?  
If i have a play\_time attribute whose type is date,how do i save the  
attribute as date type to the database when submitting form?I use  
string.to\_date to typecast before saving the attribute,but i fails.

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [August 23, 2008, 9:21am UTC](https://www.ruby-forum.com/t/about-active-record-read-and-write-attributes/146622/3 "2008-08-23T09:21:31Z")

</div>

please help me?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [August 24, 2008, 4:08am UTC](https://www.ruby-forum.com/t/about-active-record-read-and-write-attributes/146622/4 "2008-08-24T04:08:49Z")

</div>

Guo Y. wrote:

> please help me?
