-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from XiaoA/setup-models
Set up models
- Loading branch information
Showing
9 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
class QuotesController < Rulers::Controller | ||
|
||
def index | ||
quotes = FileModel.all | ||
render :index, :quotes => quotes | ||
end | ||
|
||
def new_quote | ||
attrs = { | ||
"submitter" => "web user", | ||
"quote" => "A picture is worth a thousand pixels", | ||
"attribution" => "Me" | ||
} | ||
|
||
m = FileModel.create attrs | ||
render :quote, :obj => m | ||
end | ||
|
||
def a_quote | ||
render :a_quote, :noun => :thinking | ||
end | ||
|
||
def quote_1 | ||
quote_1 = FileModel.find(1) | ||
render :quote, :obj => quote_1 | ||
end | ||
|
||
def update | ||
raise "Only POST to this route!" unless | ||
env["REQUEST_METHOD"] == "POST" | ||
body = env["rack.input"].read | ||
astr = body.split("&") | ||
params = {} | ||
astr.each do |a| | ||
name, val = a.split "=" | ||
params[name] = val | ||
end | ||
|
||
quote = FileModel.find(params["id"].to_i) | ||
quote["submitter"] = params["submitter"] | ||
quote.save | ||
|
||
rander :quote, :obj => quote | ||
end | ||
|
||
def exception | ||
raise "It's a bad one!" | ||
end | ||
|
||
|
||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<% quotes.each do |quote| %> | ||
<p> <%= quote["quote"] %> </p> | ||
<% end %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p> | ||
"<%= obj["quote"] %>" | ||
<br /> | ||
– <%= obj["attribution"] %> | ||
</p> | ||
|
||
</p> | ||
Submitted by <%= obj["submitter"] %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"submitter": "Andrew", | ||
"quote": "A penny saved is a penny earned.", | ||
"attribution": "Ben Franklin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"submitter": "web user", | ||
"quote": "A picture is worth a thousand pixels", | ||
"attribution": "Me" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"submitter": "web user", | ||
"quote": "A picture is worth a thousand pixels", | ||
"attribution": "Me" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"submitter": "web user", | ||
"quote": "A picture is worth a thousand pixels", | ||
"attribution": "Me" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"submitter": "web user", | ||
"quote": "A picture is worth a thousand pixels", | ||
"attribution": "Me" | ||
} |