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

2015-09-15 0 145
ActiveRecord中动态读取表中字段的方法
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."
>> 

遇见资源网 ruby ActiveRecord中动态读取表中字段的方法 http://www.ox520.com/16470.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务