Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added People/Person for guests and other addressbookentries. User is …
…inheriting from Person
- Loading branch information
Ayonix
committed
Apr 11, 2013
1 parent
b2b9e6e
commit efd4d3e
Showing
20 changed files
with
301 additions
and
5 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,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://coffeescript.org/ |
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 @@ | ||
// Place all the styles related to the People 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class PeopleController < ApplicationController | ||
before_action :set_person, only: [:show, :edit, :update] | ||
before_action :signed_in_user | ||
|
||
# GET /users | ||
def index | ||
@people = Person.all | ||
end | ||
|
||
# GET /users/1 | ||
def show | ||
end | ||
|
||
# GET /users/new | ||
def new | ||
@person = Person.new | ||
end | ||
|
||
# GET /users/1/edit | ||
def edit | ||
end | ||
|
||
# POST /users | ||
def create | ||
@person = Person.new(person_params) | ||
|
||
if @person.save | ||
redirect_to @person, notice: 'Person was successfully created.' | ||
else | ||
render action: 'new' | ||
end | ||
end | ||
|
||
# PATCH/PUT /users/1 | ||
def update | ||
if @person.update(person_params) | ||
login @person | ||
redirect_to @person, notice: 'User was successfully updated.' | ||
else | ||
render action: 'edit' | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_person | ||
@person = Person.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def person_params | ||
params.require(:person).permit(:firstname, :lastname, :street, :zip, :city, :email, :phone, :birthday, :misc) | ||
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 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# == Schema Information | ||
# | ||
# Table name: people | ||
# | ||
# id :integer not null, primary key | ||
# firstname :string(255) | ||
# lastname :string(255) | ||
# street :string(255) | ||
# zip :string(255) | ||
# city :string(255) | ||
# email :string(255) | ||
# phone :string(255) | ||
# birthday :date | ||
# misc :text | ||
# loginname :string(255) | ||
# remember_token :string(255) | ||
# type :string(255) | ||
# created_at :datetime | ||
# updated_at :datetime | ||
# | ||
|
||
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
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,36 @@ | ||
<%= form_for(@person) do |f| %> | ||
<% if @person.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@person.errors.count, "error") %> prohibited this user from being saved:</h2> | ||
|
||
<ul> | ||
<% @person.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
<%= f.label :firstname %> | ||
<%= f.text_field :firstname %><br /> | ||
<%= f.label :lastname %> | ||
<%= f.text_field :lastname %><br /> | ||
<%= f.label :street %> | ||
<%= f.text_field :street %><br /> | ||
<%= f.label :zip %> | ||
<%= f.text_field :zip %><br /> | ||
<%= f.label :city %> | ||
<%= f.text_field :city %><br /> | ||
<%= f.label :email %> | ||
<%= f.text_field :email %><br /> | ||
<%= f.label :phone %> | ||
<%= f.text_field :phone %><br /> | ||
<%= f.label :birthday %> | ||
<%= f.date_field :birthday, :start_year => 1950, :end_year => Date.today.year %><br /> | ||
<%= f.label :misc %> | ||
<%= f.text_area :misc %><br /> | ||
|
||
<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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<tr> | ||
<td><%= person.firstname %></td> | ||
<td><%= person.lastname %></td> | ||
<td><%= person.street %></td> | ||
<td><%= person.zip %></td> | ||
<td><%= person.city %></td> | ||
<td><%= person.email %></td> | ||
<td><%= person.phone %></td> | ||
<td><%= person.birthday %></td> | ||
<td><%= person.misc %></td> | ||
</tr> |
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,6 @@ | ||
<h1>Editing person</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @person %> | | ||
<%= link_to 'Back', persons_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,39 @@ | ||
<div class="actions"> | ||
<h1 style=""><%=t '.heading' %></h1> | ||
<a href="<%= new_person_path %>" class="button small round secondary"> | ||
<span class="icon-plus"> Neuen Eintrag Anlegen</span> | ||
</a> | ||
</div> | ||
|
||
<table> | ||
<colgroup> | ||
<col width="24%"> | ||
<col width="24%"> | ||
<col width="24%"> | ||
<col width="24%"> | ||
<col width="2%"> | ||
<col width="2%"> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th><%=t Person.human_attribute_name :firstname %></th> | ||
<th><%=t Person.human_attribute_name :lastname %></th> | ||
<th><%=t Person.human_attribute_name :email %></th> | ||
<th><%=t Person.human_attribute_name :phone %></th> | ||
<th>Aktionen</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @people.each do |person| %> | ||
<tr> | ||
<td><%= person.firstname %></td> | ||
<td><%= person.lastname %></td> | ||
<td><%= person.email %></td> | ||
<td><%= person.phone %></td> | ||
<td class="center no-linebreak"> | ||
<a href="<%= person_path(person) %>"><span class="icon-info-circled">Details</span></a> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
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 @@ | ||
<h1>New user</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', users_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,6 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<%= render @person %> | ||
|
||
<br /> | ||
<%= 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
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,20 @@ | ||
class CreatePeople < ActiveRecord::Migration | ||
def change | ||
create_table :people do |t| | ||
t.string :firstname | ||
t.string :lastname | ||
t.string :street | ||
t.string :zip | ||
t.string :city | ||
t.string :email | ||
t.string :phone | ||
t.date :birthday | ||
t.text :misc | ||
t.string :loginname | ||
t.string :remember_token | ||
t.string :type | ||
|
||
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
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,7 @@ | ||
require 'test_helper' | ||
|
||
class PeopleControllerTest < ActionController::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# 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,50 @@ | ||
# == Schema Information | ||
# | ||
# Table name: people | ||
# | ||
# id :integer not null, primary key | ||
# firstname :string(255) | ||
# lastname :string(255) | ||
# street :string(255) | ||
# zip :string(255) | ||
# city :string(255) | ||
# email :string(255) | ||
# phone :string(255) | ||
# birthday :date | ||
# misc :text | ||
# loginname :string(255) | ||
# remember_token :string(255) | ||
# type :string(255) | ||
# created_at :datetime | ||
# updated_at :datetime | ||
# | ||
|
||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html | ||
|
||
one: | ||
firstname: MyString | ||
lastname: MyString | ||
street: MyString | ||
zip: MyString | ||
city: MyString | ||
email: MyString | ||
phone: MyString | ||
birthday: 2013-04-11 | ||
misc: MyText | ||
loginname: MyString | ||
remember_token: MyString | ||
type: | ||
|
||
two: | ||
firstname: MyString | ||
lastname: MyString | ||
street: MyString | ||
zip: MyString | ||
city: MyString | ||
email: MyString | ||
phone: MyString | ||
birthday: 2013-04-11 | ||
misc: MyText | ||
loginname: MyString | ||
remember_token: MyString | ||
type: |
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 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 | 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 |