Skip to content

Commit 7d885bc

Browse files
committed
Starter code and notes for session
1 parent 3f5c00d commit 7d885bc

File tree

7 files changed

+122
-0
lines changed

7 files changed

+122
-0
lines changed

session-notes/2015-02-17/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Fundamentals of Web Development
2+
3+
**February 17, 2015**
4+
5+
## User Authentication and Authorization
6+
7+
We'll build out the user layer of a blog app.
8+
9+
There will be three kinds of users: admins, authors, and readers.
10+
11+
Each kind of user will have different levels of access (i.e. authorization levels).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.db
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'data_mapper'
4+
gem 'sinatra'
5+
6+
gem 'faker'
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.3.7)
5+
bcrypt (3.1.10)
6+
bcrypt-ruby (3.1.5)
7+
bcrypt (>= 3.1.3)
8+
data_mapper (1.2.0)
9+
dm-aggregates (~> 1.2.0)
10+
dm-constraints (~> 1.2.0)
11+
dm-core (~> 1.2.0)
12+
dm-migrations (~> 1.2.0)
13+
dm-serializer (~> 1.2.0)
14+
dm-timestamps (~> 1.2.0)
15+
dm-transactions (~> 1.2.0)
16+
dm-types (~> 1.2.0)
17+
dm-validations (~> 1.2.0)
18+
dm-aggregates (1.2.0)
19+
dm-core (~> 1.2.0)
20+
dm-constraints (1.2.0)
21+
dm-core (~> 1.2.0)
22+
dm-core (1.2.1)
23+
addressable (~> 2.3)
24+
dm-migrations (1.2.0)
25+
dm-core (~> 1.2.0)
26+
dm-serializer (1.2.2)
27+
dm-core (~> 1.2.0)
28+
fastercsv (~> 1.5)
29+
json (~> 1.6)
30+
json_pure (~> 1.6)
31+
multi_json (~> 1.0)
32+
dm-timestamps (1.2.0)
33+
dm-core (~> 1.2.0)
34+
dm-transactions (1.2.0)
35+
dm-core (~> 1.2.0)
36+
dm-types (1.2.2)
37+
bcrypt-ruby (~> 3.0)
38+
dm-core (~> 1.2.0)
39+
fastercsv (~> 1.5)
40+
json (~> 1.6)
41+
multi_json (~> 1.0)
42+
stringex (~> 1.4)
43+
uuidtools (~> 2.1)
44+
dm-validations (1.2.0)
45+
dm-core (~> 1.2.0)
46+
faker (1.4.3)
47+
i18n (~> 0.5)
48+
fastercsv (1.5.5)
49+
i18n (0.7.0)
50+
json (1.8.2)
51+
json_pure (1.8.2)
52+
multi_json (1.10.1)
53+
rack (1.6.0)
54+
rack-protection (1.5.3)
55+
rack
56+
sinatra (1.4.5)
57+
rack (~> 1.4)
58+
rack-protection (~> 1.4)
59+
tilt (~> 1.3, >= 1.3.4)
60+
stringex (1.5.1)
61+
tilt (1.4.1)
62+
uuidtools (2.1.5)
63+
64+
PLATFORMS
65+
ruby
66+
67+
DEPENDENCIES
68+
data_mapper
69+
faker
70+
sinatra
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require './database.rb'
2+
3+
require 'sinatra'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'data_mapper'
2+
3+
DataMapper.setup(:default, 'sqlite:bloggy.db')
4+
5+
class Blog
6+
include DataMapper::Resource
7+
8+
property :id, Serial
9+
property :title, String, required: true, unique: true
10+
property :content, Text, default: 'Write a blog post!'
11+
property :created_at, DateTime, required: true
12+
13+
belongs_to :author, 'User'
14+
15+
before :create do
16+
self.created_at = DateTime.now
17+
end
18+
end
19+
20+
class User
21+
include DataMapper::Resource
22+
23+
property :id, Serial
24+
property :username, String, required: true, unique: true
25+
26+
has n, :blogs, parent_key: [:id], child_key: [:author_id]
27+
end
28+
29+
DataMapper.finalize
30+
DataMapper.auto_upgrade!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'database'

0 commit comments

Comments
 (0)