-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wave 4 #107
base: mmr/master
Are you sure you want to change the base?
Wave 4 #107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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/ |
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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class PeopleController < ApplicationController | ||
|
||
def index | ||
@people = Person.all | ||
@title = "Peeps" | ||
end | ||
|
||
def show | ||
id = params[:id] | ||
@people = Person.find(id) | ||
@title = "Peep Info" | ||
end | ||
|
||
def show_tasks | ||
id = params[:id] | ||
@tasks = Person.find(id).tasks | ||
@title = "#{Person.find(id).name}'s Tasks" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are unnecessarily retrieving the person's information twice here. Each time you use |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PeopleHelper | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Person < ActiveRecord::Base | ||
has_many :tasks | ||
|
||
def not_complete | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might recommend renaming this method to be |
||
complete = self.tasks.where({:completed_at => nil}) | ||
return complete.length | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
class Task < ActiveRecord::Base | ||
|
||
belongs_to :person | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th> | ||
Person | ||
</th> | ||
<th> | ||
# of Incomplete Tasks | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @people.each do |person| %> | ||
<tr> | ||
<td><%= link_to person.name, "/people/#{person.id}" %> | ||
</td> | ||
<td> | ||
<%= person.not_complete %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th> | ||
Person | ||
</th> | ||
<th> | ||
What's Special About Them? | ||
</th> | ||
<th> | ||
Tasks | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<%= @people.name %> | ||
</td> | ||
<td> | ||
<%= @people.interests %> | ||
</td> | ||
<td> | ||
<%= button_to "See Tasks", { action: "show_tasks", id: @people.id }, method: :get %> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% @tasks.each do |task| %> | ||
<p> | ||
<%= task.name %> | ||
</p> | ||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreatePeople < ActiveRecord::Migration | ||
def change | ||
create_table :people do |t| | ||
t.string :name | ||
t.string :interests | ||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class ModifyTasks < ActiveRecord::Migration | ||
def change | ||
change_table :tasks do |t| | ||
remove_column :tasks, :completed | ||
add_column :tasks, :person_id, :integer | ||
end | ||
|
||
add_index :tasks, :person_id | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some of the styles below, you want to separate multi-word styles with the
-
rather than the_