version: rails4
3 创建Active Record 模型
创建Active Record models是非常简单的。你所需要做的就是实现 ActiveRecord::Base的子类, 你可以参考下面:
classProduct < ActiveRecord::Base end |
这会创建一个Product model,在数据库中映射一个products数据表。你将能够映射数据表每一行的列对应于模型实例的特性。正如同products数据表是用下文的SQL语句来创建的:
CREATETABLEproducts ( id int(11) NOTNULLauto_increment, namevarchar(255), PRIMARYKEY (id) ); |
基于上文的数据表模式,你将能够编写如下的代码:
p = Product.new p.name = "Some Book" puts p.name # "Some Book" |
original text: http://guides.rubyonrails.org/active_record_basics.html#creating-active-record-models
相关推荐
Covers the basics of searching Active Directory: creating, modifying, and deleting objects, using LDAP controls, and importing and exporting data using LDAP Data Interchange Format (LDIF) and comma-...
And almost all of those books actually do a great job of introducing you to the basics of Active Record; they go a long way toward getting you started with the library. However, because they ...
ffmpeg basics ffmpeg basics ffmpeg basics ffmpeg basics ffmpeg basics
MATLAB basics for creating a script file and using it...
Qt 3D 基础 , 来自KDAB的50页基础教程,很好的资源, 适合新手学习,Qt3D的基础教程pdf.
Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali (AZW3)
Blender 3D Basics_Beginner's Guide,Second Edition-Packt Publishing(2014)
MPLS BasicsMPLS Basics
FFmpeg Basics
Learn Autodesk Inventor 2018 Basics 3D Modeling, 2D Graphics, and Assembly Design 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者...
Stepper Motor Basics
Python Basics with Numpy Python Basics with Numpy Python Basics with Numpy
This book starts with the basics of probability theory and graph theory, then goes on to discuss various models and inference algorithms. All the different types of models are discussed along with ...
iOS 11 Programming Fundamentals with Swift Swift, Xcode, and Cocoa Basics 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
LabWindows CVI BASICS I & II 英文版的都是
FFmpeg Basics = 119.pdf
The Basics of Cloud Computing
Welcome to HTML Basics. This workshop leads you through the basics of Hyper Text Markup Language (HTML). HTML is the building block for web pages. You will learn to use HTML to author an HTML page to ...
Basics of Holography.pdf