- 浏览: 145420 次
- 性别:
- 来自: 北京
文章分类
最新评论
class Customer < ActiveRecord::Base attr_accessible :name, :nickname end customer = Customer.new(:name => "David", :nickname => "Dave", :credit_rating => "Excellent") customer.credit_rating # => nil customer.attributes = { :name => "Jolly fellow", :credit_rating => "Superb" } customer.credit_rating # => nil customer.credit_rating = "Average" customer.credit_rating # => "Average"
class Customer < ActiveRecord::Base attr_protected :credit_rating end customer = Customer.new("name" => David, "credit_rating" => "Excellent") customer.credit_rating # => nil customer.attributes = { "description" => "Jolly fellow", "credit_rating" => "Superb" } customer.credit_rating # => nil customer.credit_rating = "Average" customer.credit_rating # => "Average
class CreditCard < ActiveRecord::Base # Strip everything but digits, so the user can specify "555 234 34" or # "5552-3434" or both will mean "55523434" def before_validation_on_create self.number = number.gsub(/[^0-9]/, "") if attribute_present?("number") end end class Subscription < ActiveRecord::Base before_create :record_signup private def record_signup self.signed_up_on = Date.today end end class Firm < ActiveRecord::Base # Destroys the associated clients and people when the firm is destroyed before_destroy { |record| Person.destroy_all "firm_id = #{record.id}" } before_destroy { |record| Client.destroy_all "client_of = #{record.id}" } end
发表评论
-
Google App Engine and others
2010-09-15 11:27 755有用的技术文章 先记载 有空 研究下 さくっとRails ... -
基于jquery和mini_magick的图片裁剪
2010-09-15 11:07 1425引用网址 http://duyouhua1214.iteye ... -
ruby gem相关命令使用
2010-08-26 12:45 1556gem相关命令使用 1.显示gem的帮助和版本 gem – ... -
深入理解alias, alias_method和alias_method_chain
2010-08-06 17:14 942http://blackanger.blog.51cto.co ... -
Rails 3 特点
2010-08-06 16:38 865真的想留下来 http://railslove.com/w ... -
Fix N+1 Queries
2010-08-06 16:16 882http://rails-bestpractices.com/ ... -
query-reviewer sql explain and review in the page
2010-08-06 12:20 1288引用网址 http://github.com/dsboulde ... -
request-log-analyzer log分析工具
2010-08-06 12:03 1570参考网址: http://github.com/wvanber ... -
IE7 Bug导致Rails Session保存失败
2010-08-06 10:56 945http://www.letrails.cn/archives ... -
Rails保存记录而不更新时间戳
2010-08-06 10:54 1314引用地址: http://www.letrails.cn/a ... -
how to generate qrcode on ror
2010-02-04 16:27 8421. In your rails project, in ... -
rmagick ror 上 安装
2009-11-18 09:06 822rmgick 安装规范 ror很多人现在在用了,但是发现 ... -
Update Rails to 2.2.2 (Rails 2.2.2)
2009-03-08 14:53 952gem install -v=2.2.2 rails Suc ... -
Use helpers in controllers or models
2009-01-19 16:22 882引用http://snipplr.com/view/2505/ ... -
open-flash-chart
2008-11-07 14:07 2394http://pullmonkey.com/2008/7/23 ... -
rake db:migrate
2008-11-07 11:58 1241【ruby on rails】rake db:migrate ... -
rss maker
2008-11-07 11:43 1077http://gdgdlog.net/log/show/130 ... -
acts_as_authenticated
2008-11-07 11:35 1055ruby script/plugin install act ... -
validates
2008-11-07 11:24 1033先週ずっとインフルエンザでダウンしてました。 今日はvail ... -
rails で model の変更を監視するプラグイン
2008-11-07 11:12 1339acts_as_modified モデルの変更を監視して、各 ...
相关推荐
java常用的API笔记,李兴华老师写的,适合java初学者的学习,谢谢!
人人API笔记(1)文档 手把手renrenAPI教程
webApi笔记.zip
人人API笔记(1)实例 手把手人人API实例教程
WindowsAPI笔记 WindowsAPI笔记 WindowsAPI笔记 WindowsAPI笔记 WindowsAPI笔记
API笔记整理完之后加以完善
VC编程练习之API笔记(三)代码,对应博客:http://blog.csdn.net/sui_yirufeng/article/details/17484499 希望对各位有用!一起学习!
Java核心API个人笔记,如果有错误和意见,请在评论中提出
整理了之前使用lua capi时不足的地方
API笔记本 交互式API笔记本-。 发展 # Install dependencies npm install npm install -g grunt-cli # Start development server grunt # open http://localhost:3000 # Run tests in the browser (requires the ...
vc编程练习的代码,免费共享。一起学习。
MFC练习代码,都是一些常用控件的基本使用方法,希望对初学者有帮助.
印象笔记api上传笔记样式,比较主流的样式,对于阅读器开发有用
WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAddConnection3 创建同一个网络资源的连接 WNetCancelConnection 结束一个网络连接 ...
HotApp云笔记 - 精品开源demo-基于免费API(源代码+截图)HotApp云笔记 - 精品开源demo-基于免费API(源代码+截图)HotApp云笔记 - 精品开源demo-基于免费API(源代码+截图)HotApp云笔记 - 精品开源demo-基于免费API(源...
API总结的一些笔记,可以下来看看。 学习API可能有些用处。
使用C++API编写的笔记本程序 类似window自带笔记本
Windows API 学习笔记
图像API学习笔记 开发环境 DELPHI 用实例介绍各种API函数
Ext ExtJs API详解 Ext API详解--笔记