ActiveRecord中动态读取表中字段的方法

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

script/console 
Loading development environment (Rails 2.3.11)
>> p = Package.new
=> #<Package id: nil, name: nil, build: nil, notes: nil, user_id: nil, created_at: nil, updated_at: nil, brew_tag_id: nil, label_id: nil, created_by: nil, version: nil, ver: nil, brew_link: nil, group_id: nil, artifact_id: nil>
>> p.write_attribute(:name, 'abc')
=> "abc"
>> p.name
=> "abc"
>> p.write_attribute("notes", "hello, world.")
=> "hello, world."
>> p.notes
=> "<p>hello, world.</p>"
>> p.read_attribute(:notes)
=> "hello, world."
>>