-
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.
- Loading branch information
Jarl Friis
committed
Nov 10, 2010
1 parent
ff11980
commit ba9a79c
Showing
16 changed files
with
285 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
class NotesController < ApplicationController | ||
# GET /notes | ||
# GET /notes.xml | ||
def index | ||
@notes = Note.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @notes } | ||
end | ||
end | ||
|
||
# GET /notes/1 | ||
# GET /notes/1.xml | ||
def show | ||
@note = Note.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @note } | ||
end | ||
end | ||
|
||
# GET /notes/new | ||
# GET /notes/new.xml | ||
def new | ||
@note = Note.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @note } | ||
end | ||
end | ||
|
||
# GET /notes/1/edit | ||
def edit | ||
@note = Note.find(params[:id]) | ||
end | ||
|
||
# POST /notes | ||
# POST /notes.xml | ||
def create | ||
@note = Note.new(params[:note]) | ||
|
||
respond_to do |format| | ||
if @note.save | ||
format.html { redirect_to(@note, :notice => 'Note was successfully created.') } | ||
format.xml { render :xml => @note, :status => :created, :location => @note } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @note.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /notes/1 | ||
# PUT /notes/1.xml | ||
def update | ||
@note = Note.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @note.update_attributes(params[:note]) | ||
format.html { redirect_to(@note, :notice => 'Note was successfully updated.') } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @note.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /notes/1 | ||
# DELETE /notes/1.xml | ||
def destroy | ||
@note = Note.find(params[:id]) | ||
@note.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(notes_url) } | ||
format.xml { head :ok } | ||
end | ||
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,2 @@ | ||
module NotesHelper | ||
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,2 @@ | ||
class Note < ActiveRecord::Base | ||
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,17 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> | ||
<title>Notes: <%= controller.action_name %></title> | ||
<%= stylesheet_link_tag 'scaffold' %> | ||
</head> | ||
<body> | ||
|
||
<p style="color: green"><%= notice %></p> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
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,12 @@ | ||
<h1>Editing note</h1> | ||
|
||
<% form_for(@note) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.submit 'Update' %> | ||
</p> | ||
<% end %> | ||
|
||
<%= link_to 'Show', @note %> | | ||
<%= link_to 'Back', notes_path %> |
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,18 @@ | ||
<h1>Listing notes</h1> | ||
|
||
<table> | ||
<tr> | ||
</tr> | ||
|
||
<% @notes.each do |note| %> | ||
<tr> | ||
<td><%= link_to 'Show', note %></td> | ||
<td><%= link_to 'Edit', edit_note_path(note) %></td> | ||
<td><%= link_to 'Destroy', note, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New note', new_note_path %> |
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,11 @@ | ||
<h1>New note</h1> | ||
|
||
<% form_for(@note) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.submit 'Create' %> | ||
</p> | ||
<% end %> | ||
|
||
<%= link_to 'Back', notes_path %> |
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,3 @@ | ||
|
||
<%= link_to 'Edit', edit_note_path(@note) %> | | ||
<%= link_to 'Back', notes_path %> |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateNotes < ActiveRecord::Migration | ||
def self.up | ||
create_table :notes do |t| | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :notes | ||
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 @@ | ||
# Logfile created on Wed Nov 10 13:24:12 +0100 2010 |
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,54 @@ | ||
body { background-color: #fff; color: #333; } | ||
|
||
body, p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { color: #000; } | ||
a:visited { color: #666; } | ||
a:hover { color: #fff; background-color:#000; } | ||
|
||
.fieldWithErrors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#errorExplanation { | ||
width: 400px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 12px; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
} | ||
|
||
#errorExplanation h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
|
||
#errorExplanation p { | ||
color: #333; | ||
margin-bottom: 0; | ||
padding: 5px; | ||
} | ||
|
||
#errorExplanation ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
|
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,11 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the '{}' from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
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,45 @@ | ||
require 'test_helper' | ||
|
||
class NotesControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:notes) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create note" do | ||
assert_difference('Note.count') do | ||
post :create, :note => { } | ||
end | ||
|
||
assert_redirected_to note_path(assigns(:note)) | ||
end | ||
|
||
test "should show note" do | ||
get :show, :id => notes(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, :id => notes(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should update note" do | ||
put :update, :id => notes(:one).to_param, :note => { } | ||
assert_redirected_to note_path(assigns(:note)) | ||
end | ||
|
||
test "should destroy note" do | ||
assert_difference('Note.count', -1) do | ||
delete :destroy, :id => notes(:one).to_param | ||
end | ||
|
||
assert_redirected_to notes_path | ||
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 @@ | ||
require 'test_helper' | ||
|
||
class NotesHelperTest < ActionView::TestCase | ||
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,8 @@ | ||
require 'test_helper' | ||
|
||
class NoteTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |