-
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
Franco Sellitto
committed
Jun 8, 2011
1 parent
c38206f
commit 60ec0c8
Showing
16 changed files
with
294 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# Place all the behaviors and hooks related to the matching controller here. | |||
# All this logic will automatically be available in application.js. | |||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
/* | |||
Place all the styles related to the matching controller here. | |||
They will automatically be included in application.css. | |||
You can use Sass (SCSS) here: http://sass-lang.com/ | |||
*/ |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
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; | |||
&:visited { color: #666; } | |||
&:hover { color: #fff; background-color:#000; } | |||
} | |||
|
|||
div.field, div.actions { | |||
margin-bottom: 10px; | |||
} | |||
|
|||
#notice { | |||
color: green; | |||
} | |||
|
|||
.field_with_errors { | |||
padding: 2px; | |||
background-color: red; | |||
display: table; | |||
} | |||
|
|||
#error_explanation { | |||
width: 450px; | |||
border: 2px solid red; | |||
padding: 7px; | |||
padding-bottom: 0; | |||
margin-bottom: 20px; | |||
background-color: #f0f0f0; | |||
|
|||
h2 { | |||
text-align: left; | |||
font-weight: bold; | |||
padding: 5px 5px 5px 15px; | |||
font-size: 12px; | |||
margin: -7px; | |||
margin-bottom: 0px; | |||
background-color: #c00; | |||
color: #fff; | |||
} | |||
|
|||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,83 @@ | |||
class PeopleController < ApplicationController | |||
# GET /people | |||
# GET /people.json | |||
def index | |||
@people = Person.all | |||
|
|||
respond_to do |format| | |||
format.html # index.html.erb | |||
format.json { render :json => @people } | |||
end | |||
end | |||
|
|||
# GET /people/1 | |||
# GET /people/1.json | |||
def show | |||
@person = Person.find(params[:id]) | |||
|
|||
respond_to do |format| | |||
format.html # show.html.erb | |||
format.json { render :json => @person } | |||
end | |||
end | |||
|
|||
# GET /people/new | |||
# GET /people/new.json | |||
def new | |||
@person = Person.new | |||
|
|||
respond_to do |format| | |||
format.html # new.html.erb | |||
format.json { render :json => @person } | |||
end | |||
end | |||
|
|||
# GET /people/1/edit | |||
def edit | |||
@person = Person.find(params[:id]) | |||
end | |||
|
|||
# POST /people | |||
# POST /people.json | |||
def create | |||
@person = Person.new(params[:person]) | |||
|
|||
respond_to do |format| | |||
if @person.save | |||
format.html { redirect_to @person, :notice => 'Person was successfully created.' } | |||
format.json { render :json => @person, :status => :created, :location => @person } | |||
else | |||
format.html { render :action => "new" } | |||
format.json { render :json => @person.errors, :status => :unprocessable_entity } | |||
end | |||
end | |||
end | |||
|
|||
# PUT /people/1 | |||
# PUT /people/1.json | |||
def update | |||
@person = Person.find(params[:id]) | |||
|
|||
respond_to do |format| | |||
if @person.update_attributes(params[:person]) | |||
format.html { redirect_to @person, :notice => 'Person was successfully updated.' } | |||
format.json { head :ok } | |||
else | |||
format.html { render :action => "edit" } | |||
format.json { render :json => @person.errors, :status => :unprocessable_entity } | |||
end | |||
end | |||
end | |||
|
|||
# DELETE /people/1 | |||
# DELETE /people/1.json | |||
def destroy | |||
@person = Person.find(params[:id]) | |||
@person.destroy | |||
|
|||
respond_to do |format| | |||
format.html { redirect_to people_url } | |||
format.json { 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
module PeopleHelper | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
class Person < 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
<%= form_for(@person) do |f| %> | |||
<% if @person.errors.any? %> | |||
<div id="error_explanation"> | |||
<h2><%= pluralize(@person.errors.count, "error") %> prohibited this person from being saved:</h2> | |||
|
|||
<ul> | |||
<% @person.errors.full_messages.each do |msg| %> | |||
<li><%= msg %></li> | |||
<% end %> | |||
</ul> | |||
</div> | |||
<% end %> | |||
|
|||
<div class="field"> | |||
<%= f.label :name %><br /> | |||
<%= f.text_field :name %> | |||
</div> | |||
<div class="actions"> | |||
<%= f.submit %> | |||
</div> | |||
<% 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
<h1>Editing person</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Show', @person %> | | |||
<%= link_to 'Back', people_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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
<h1>Listing people</h1> | |||
|
|||
<table> | |||
<tr> | |||
<th>Name</th> | |||
<th></th> | |||
<th></th> | |||
<th></th> | |||
</tr> | |||
|
|||
<% @people.each do |person| %> | |||
<tr> | |||
<td><%= person.name %></td> | |||
<td><%= link_to 'Show', person %></td> | |||
<td><%= link_to 'Edit', edit_person_path(person) %></td> | |||
<td><%= link_to 'Destroy', person, :confirm => 'Are you sure?', :method => :delete %></td> | |||
</tr> | |||
<% end %> | |||
</table> | |||
|
|||
<br /> | |||
|
|||
<%= link_to 'New Person', new_person_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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<h1>New person</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Back', people_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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
<p id="notice"><%= notice %></p> | |||
|
|||
<p> | |||
<b>Name:</b> | |||
<%= @person.name %> | |||
</p> | |||
|
|||
|
|||
<%= link_to 'Edit', edit_person_path(@person) %> | | |||
<%= link_to 'Back', people_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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
class CreatePeople < ActiveRecord::Migration | |||
def change | |||
create_table :people do |t| | |||
t.string :name | |||
|
|||
t.timestamps | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html | |||
|
|||
one: | |||
name: MyString | |||
|
|||
two: | |||
name: MyString |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
require 'test_helper' | |||
|
|||
class PeopleControllerTest < ActionController::TestCase | |||
setup do | |||
@person = people(:one) | |||
end | |||
|
|||
test "should get index" do | |||
get :index | |||
assert_response :success | |||
assert_not_nil assigns(:people) | |||
end | |||
|
|||
test "should get new" do | |||
get :new | |||
assert_response :success | |||
end | |||
|
|||
test "should create person" do | |||
assert_difference('Person.count') do | |||
post :create, :person => @person.attributes | |||
end | |||
|
|||
assert_redirected_to person_path(assigns(:person)) | |||
end | |||
|
|||
test "should show person" do | |||
get :show, :id => @person.to_param | |||
assert_response :success | |||
end | |||
|
|||
test "should get edit" do | |||
get :edit, :id => @person.to_param | |||
assert_response :success | |||
end | |||
|
|||
test "should update person" do | |||
put :update, :id => @person.to_param, :person => @person.attributes | |||
assert_redirected_to person_path(assigns(:person)) | |||
end | |||
|
|||
test "should destroy person" do | |||
assert_difference('Person.count', -1) do | |||
delete :destroy, :id => @person.to_param | |||
end | |||
|
|||
assert_redirected_to people_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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
require 'test_helper' | |||
|
|||
class PeopleHelperTest < 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
require 'test_helper' | |||
|
|||
class PersonTest < ActiveSupport::TestCase | |||
# test "the truth" do | |||
# assert true | |||
# end | |||
end |