This repository has been archived by the owner on Jun 12, 2018. It is now read-only.
-
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
James Miller
committed
Nov 2, 2009
0 parents
commit d01c840
Showing
82 changed files
with
8,633 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,7 @@ | ||
config/app_config.yml | ||
config/database.yml | ||
.DS_Store | ||
log/*.log | ||
tmp/**/* | ||
log/*.pid | ||
public/system/* |
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 @@ | ||
Application for managing a wedding guest list |
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,10 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require(File.join(File.dirname(__FILE__), 'config', 'boot')) | ||
|
||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
require 'tasks/rails' |
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 @@ | ||
class ApplicationController < ActionController::Base | ||
|
||
helper :all | ||
protect_from_forgery | ||
|
||
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,45 @@ | ||
class FamiliesController < ApplicationController | ||
def index | ||
@families = Family.all | ||
end | ||
|
||
def show | ||
@family = Family.find(params[:id]) | ||
end | ||
|
||
def new | ||
@family = Family.new | ||
@person = @family.people.build | ||
end | ||
|
||
def create | ||
@family = Family.new(params[:family]) | ||
if @family.save | ||
flash[:notice] = "Successfully created family." | ||
redirect_to @family | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
|
||
def edit | ||
@family = Family.find(params[:id]) | ||
end | ||
|
||
def update | ||
@family = Family.find(params[:id]) | ||
if @family.update_attributes(params[:family]) | ||
flash[:notice] = "Successfully updated family." | ||
redirect_to @family | ||
else | ||
render :action => 'edit' | ||
end | ||
end | ||
|
||
def destroy | ||
@family = Family.find(params[:id]) | ||
@family.destroy | ||
flash[:notice] = "Successfully destroyed family." | ||
redirect_to families_url | ||
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,44 @@ | ||
class FoodsController < ApplicationController | ||
def index | ||
@foods = Food.all | ||
end | ||
|
||
def show | ||
@food = Food.find(params[:id]) | ||
end | ||
|
||
def new | ||
@food = Food.new | ||
end | ||
|
||
def create | ||
@food = Food.new(params[:food]) | ||
if @food.save | ||
flash[:notice] = "Successfully created food." | ||
redirect_to @food | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
|
||
def edit | ||
@food = Food.find(params[:id]) | ||
end | ||
|
||
def update | ||
@food = Food.find(params[:id]) | ||
if @food.update_attributes(params[:food]) | ||
flash[:notice] = "Successfully updated food." | ||
redirect_to @food | ||
else | ||
render :action => 'edit' | ||
end | ||
end | ||
|
||
def destroy | ||
@food = Food.find(params[:id]) | ||
@food.destroy | ||
flash[:notice] = "Successfully destroyed food." | ||
redirect_to foods_url | ||
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,44 @@ | ||
class GroupsController < ApplicationController | ||
def index | ||
@groups = Group.all | ||
end | ||
|
||
def show | ||
@group = Group.find(params[:id]) | ||
end | ||
|
||
def new | ||
@group = Group.new | ||
end | ||
|
||
def create | ||
@group = Group.new(params[:group]) | ||
if @group.save | ||
flash[:notice] = "Successfully created group." | ||
redirect_to @group | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
|
||
def edit | ||
@group = Group.find(params[:id]) | ||
end | ||
|
||
def update | ||
@group = Group.find(params[:id]) | ||
if @group.update_attributes(params[:group]) | ||
flash[:notice] = "Successfully updated group." | ||
redirect_to @group | ||
else | ||
render :action => 'edit' | ||
end | ||
end | ||
|
||
def destroy | ||
@group = Group.find(params[:id]) | ||
@group.destroy | ||
flash[:notice] = "Successfully destroyed group." | ||
redirect_to groups_url | ||
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,7 @@ | ||
class MainController < ApplicationController | ||
|
||
def index | ||
@groups = Group.all(:order => :name, :include => :families) | ||
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,21 @@ | ||
module ApplicationHelper | ||
|
||
def remove_child_link(name, f) | ||
f.hidden_field(:_delete) + link_to_function(name, "remove_fields(this)") | ||
end | ||
|
||
def add_child_link(name, f, method) | ||
fields = new_child_fields(f, method) | ||
link_to_function(name, h("insert_fields(this, \"#{method}\", \"#{escape_javascript(fields)}\")")) | ||
end | ||
|
||
def new_child_fields(form_builder, method, options = {}) | ||
options[:object] ||= form_builder.object.class.reflect_on_association(method).klass.new | ||
options[:partial] ||= method.to_s.singularize | ||
options[:form_builder_local] ||= :f | ||
form_builder.fields_for(method, options[:object], :child_index => "new_#{method}") do |f| | ||
render(:partial => options[:partial], :locals => { options[:form_builder_local] => f }) | ||
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 FamiliesHelper | ||
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 FoodsHelper | ||
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 GroupsHelper | ||
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,22 @@ | ||
# These helper methods can be called in your template to set variables to be used in the layout | ||
# This module should be included in all views globally, | ||
# to do so you may need to add this line to your ApplicationController | ||
# helper :layout | ||
module LayoutHelper | ||
def title(page_title, show_title = true) | ||
@content_for_title = page_title.to_s | ||
@show_title = show_title | ||
end | ||
|
||
def show_title? | ||
@show_title | ||
end | ||
|
||
def stylesheet(*args) | ||
content_for(:head) { stylesheet_link_tag(*args) } | ||
end | ||
|
||
def javascript(*args) | ||
content_for(:head) { javascript_include_tag(*args) } | ||
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 MainHelper | ||
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 @@ | ||
class Family < ActiveRecord::Base | ||
|
||
belongs_to :group | ||
|
||
has_many :people, :dependent => :destroy | ||
|
||
validates_presence_of :name | ||
|
||
accepts_nested_attributes_for :people, :allow_destroy => :true | ||
|
||
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 @@ | ||
class Food < ActiveRecord::Base | ||
|
||
has_many :people | ||
|
||
validates_presence_of :name | ||
|
||
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,6 @@ | ||
class Group < ActiveRecord::Base | ||
|
||
has_many :families, :dependent => :destroy | ||
has_many :people, :through => :families | ||
|
||
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 @@ | ||
class Person < ActiveRecord::Base | ||
|
||
belongs_to :family, :counter_cache => true | ||
belongs_to :food | ||
|
||
validates_presence_of :name | ||
|
||
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,35 @@ | ||
<% form_for @family do |f| %> | ||
<%= f.error_messages %> | ||
<p> | ||
<%= f.label :name %><br /> | ||
<%= f.text_field :name, :class => "text medium" %> | ||
</p> | ||
<p> | ||
<%= f.label :address %><br /> | ||
<%= f.text_area :address, :rows => 4, :cols => 50, :class => "textarea" %> | ||
</p> | ||
<p> | ||
<%= f.label :phone %><br /> | ||
<%= f.text_field :phone, :class => "text medium" %> | ||
</p> | ||
<p> | ||
<%= f.label :email %><br /> | ||
<%= f.text_field :email, :class => "text medium" %> | ||
</p> | ||
<p> | ||
<%= f.label :group_id, "Group" %><br /> | ||
<%= f.select :group_id, Group.all(:order => :name).map { |g| [g.name, g.id] }, {:include_blank => "Select group..."}, :class => "drop" %> | ||
</p> | ||
<p> | ||
<%= f.label :list, "List" %><br /> | ||
<%= f.select :list, [ "A List", "B List"], {}, :class => "drop" %> | ||
</p> | ||
|
||
<h2>People in this family</h2> | ||
<% f.fields_for :people do |pf| %> | ||
<%= render :partial => 'person', :locals => { :f => pf } %> | ||
<% end %> | ||
<p><%= add_child_link "Add person", f, :people %></p> | ||
|
||
<p><%= f.submit "Save" %></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,11 @@ | ||
<div class="fields"> | ||
<p> | ||
<%= f.text_field :name, :class => "text short" %> | ||
<%= f.select :attending, [["Yes", true], ["No", false]], {:include_blank => "Attending?"}, :class => "drop" %> | ||
<%= f.select :food_id, Food.all(:order => :name).map { |food| [food.name, food.id] }, {:include_blank => "Select food..."}, :class => "drop" %> | ||
<%= remove_child_link "Remove", f %> | ||
</p> | ||
</div> |
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 @@ | ||
<% title "Edit Family" %> | ||
<%= render :partial => 'form' %> | ||
|
||
<p> | ||
<%= link_to "Show", @family %> | | ||
<%= link_to "View All", families_path %> | ||
</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,23 @@ | ||
<% title "Families" %> | ||
|
||
<table> | ||
<tr> | ||
<th>Name</th> | ||
<th>People Count</th> | ||
<th>Address</th> | ||
<th>Group</th> | ||
</tr> | ||
<% for family in @families %> | ||
<tr> | ||
<td><%=h family.name %></td> | ||
<td><%=h family.people_count %></td> | ||
<td><%=h family.address %></td> | ||
<td><%=h family.group_id %></td> | ||
<td><%= link_to "Show", family %></td> | ||
<td><%= link_to "Edit", edit_family_path(family) %></td> | ||
<td><%= link_to "Destroy", family, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<p><%= link_to "New Family", new_family_path %></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 @@ | ||
<% title "New Family" %> | ||
<%= render :partial => 'form' %> | ||
|
||
<p><%= link_to "Back to List", families_path %></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,24 @@ | ||
<% title "Family" %> | ||
|
||
<p> | ||
<strong>Name:</strong> | ||
<%=h @family.name %> | ||
</p> | ||
<p> | ||
<strong>People Count:</strong> | ||
<%=h @family.people_count %> | ||
</p> | ||
<p> | ||
<strong>Address:</strong> | ||
<%=h @family.address %> | ||
</p> | ||
<p> | ||
<strong>Group:</strong> | ||
<%=h @family.group_id %> | ||
</p> | ||
|
||
<p> | ||
<%= link_to "Edit", edit_family_path(@family) %> | | ||
<%= link_to "Destroy", @family, :confirm => 'Are you sure?', :method => :delete %> | | ||
<%= link_to "View All", families_path %> | ||
</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,8 @@ | ||
<% form_for @food do |f| %> | ||
<%= f.error_messages %> | ||
<p> | ||
<%= f.label :name %><br /> | ||
<%= f.text_field :name %> | ||
</p> | ||
<p><%= f.submit "Submit" %></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,8 @@ | ||
<% title "Edit Food" %> | ||
<%= render :partial => 'form' %> | ||
|
||
<p> | ||
<%= link_to "Show", @food %> | | ||
<%= link_to "View All", foods_path %> | ||
</p> |
Oops, something went wrong.