15. /db/schema.rb
ActiveRecord::Schema.define(:version => 0) do
create_table :posts do |t|
t.string :title
t.text :description
t.string :url
end
end
/app/models/post.rb
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
16. /blog/models.py
class Post(models.Model):
title = models.CharField( max_length=120 )
description = models.TextField()
url = models.URLField( verify_exists=True )
user = models.ForeignKey( User )
class Comment(models.Model):
...
post = models.ForeignKey( Post, related_name=„comments‟)
17. class AddDetailsToProducts < ActiveRecord::Migration
def self.up
add_column :posts, :category, :string
end
def self.down
remove_column :posts, :category
end
end
rake db:migrate
18. Class Table Inheritance
class Person(models.Model):
name = models.CharField( max_length=120 )
class Worker( Person ):
job = models.CharField( max_length=120 )
class Client( Person ):
email = models.EmailField()
40. • Web applications for information management
• Reusable components
• Common functionalities built-in
- Authentication
- Authorization (permissions)
- Image or file upload
...
41. • Less common web applications
• AJAX intensive
• Dedicated hosting and support
• Heavy testing
• Specialized tools