- 博客(9)
- 收藏
- 关注
转载 Deep in CRUD
What a hash is? Hash : Series of key value pairs. b = { id: 3, status: "I just ate some delicious brains", zombie: "Jim" } Has...
2014-05-29 18:07:00
119
转载 Active record Assocations
关联的类型 在Rails中,关联是两个Active Record模型之间的关系。关联使用宏的方式实现,用声明的形式为模型添加功能。 Rails支持六种关联: - belongs_to - has_one - has_many - has_many :th...
2014-05-28 11:48:00
136
转载 Active Record回调
对象的生命周期 回调可以再对象的状态改变之前或之后触发指定的逻辑操作。 回调简介 回调是在对象生命周期的特定时刻执行的方法。回调方法可以在Active Record对象创建,保存,更新,删除,验证或是从数据库中读出时执行。 注册回调 在使用回调之前,需要先...
2014-05-27 14:34:00
139
转载 Active Record数据验证
数据验证简介 class Person < ActiveRecord::Base validates :name, presence: trueendPerson.create(name, "Jeek Wong").valid? #=> truePerson.cr...
2014-05-23 14:58:00
167
转载 Rails Database Migrations
迁移简介 迁移使用一种统一,简单的方式,按照时间顺序修改数据库的模式。 迁移使用Ruby DSL编写,不需手动编写SQL语句,对数据库的操作和所用的数据库种类无关。 可以将每个迁移看做是数据库的一个修订版本。数据库初始时为空,各个迁移会添加或是删除数据表,字段或是记录。 ...
2014-05-22 15:56:00
141
转载 Active Record Basic
Active Record是什么 Active Record是MVC中的M(模型),处理数据和业务逻辑。 Active Record负责创建和使用需要持久存入数据库中的数据。 Active Record实现了Active Record模式,是一种对象关系映射系统。 ...
2014-05-22 10:30:00
123
转载 Finding Your Way Around Rails
一、application directory 1. config.ru:configures the Rack Webserver Interface, either to create Rails Meta applications or to use Rack Midd...
2014-05-19 11:17:00
91
转载 Chapter 3: Classes, Objects and Variables
class BookInStock def initialize(isbn, price) @isbn = isbn @price = Float(price) endend a_book = BookInStock.newanother_book = BookI...
2014-05-07 16:42:00
117
转载 Chapter 2 : Ruby.new
一、Ruby is an object-oriented language a class is a combination of state and methods that use that state the world object is used int...
2014-05-05 13:58:00
148
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人