-
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
Hrw/master #112
base: hrw/master
Are you sure you want to change the base?
Hrw/master #112
Changes from all commits
3f8281c
3a8f218
5e3bd37
795e7d4
f9b26b5
9e69113
e6af9c8
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 |
---|---|---|
|
@@ -49,3 +49,7 @@ li { | |
#completed { | ||
text-decoration: line-through; | ||
} | ||
|
||
#people_list { | ||
text-align: center; | ||
} |
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,17 @@ | ||
class PeopleController < ApplicationController | ||
def index | ||
@people = Person.all | ||
end | ||
|
||
def show | ||
id = params[:person_id] | ||
@person = Person.find(id) | ||
end | ||
|
||
def tasks | ||
id = params[:person_id] | ||
@person = Person.find(id) | ||
@finished_tasks= @person.complete_tasks | ||
@remaining_tasks= @person.incomplete_tasks | ||
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,15 @@ | ||
class Person < ActiveRecord::Base | ||
has_many :tasks | ||
|
||
def incomplete_tasks | ||
t = self.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. I would recommend a more meaningful variable name instead of |
||
t = t.where(completed: nil) | ||
return t | ||
end | ||
|
||
def complete_tasks | ||
t = self.tasks | ||
t = t.where.not(completed: nil) | ||
return t | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class Task < ActiveRecord::Base | ||
belongs_to :person | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1> Here are each of the people you can assign to a task </h1> | ||
<ul id=people_list> | ||
<% @people.each do |p| %> | ||
<li> | ||
Task left to do: <%=p.incomplete_tasks.count%> | ||
<br><a href=people/<%=p.id%>><%= p.name %></a> | ||
</li> | ||
<%end%> | ||
</ul> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1><%[email protected]%> </h1> | ||
|
||
<li><a href=<%[email protected]%>/tasks>Click here to see all of <%[email protected]%>'s tasks </a> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<h1> <%[email protected]%>'s' Incomplete Tasks: </h1> | ||
<ul id=person_task_list> | ||
<% @remaining_tasks.each do |t| %> | ||
<li> | ||
Task: <%=t.name%> | ||
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. For readability, it is best practice to add a space after the = and before the last % so: |
||
<br>Description: <%=t.description%> | ||
</li> | ||
<%end%> | ||
</ul> | ||
|
||
<br> | ||
|
||
<h1> <%[email protected]%>'s' Completed Tasks: </h1> | ||
<ul id=person_task_list> | ||
<% @finished_tasks.each do |t| %> | ||
<li> | ||
Task: <%=t.name%> | ||
<br>Description: <%=t.description%> | ||
<br>Completed: <%=t.completed%> | ||
</li> | ||
<%end%> | ||
</ul> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<h1> <%[email protected]%> </h1> | ||
<h5><%[email protected]%></h5> | ||
<h1> Task: <%[email protected]%> </h1> | ||
<h5>Description: <%[email protected]%></h5> | ||
<h5>Assigned to: <%= @task.person.name%></h5> | ||
<h5><%[email protected]%></h5> | ||
|
||
<li><a href=<%[email protected]%>/edit>UPDATE!</a> |
Original file line number | 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 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| | ||
add_column :tasks, :person_id, :integer | ||
|
||
end | ||
#first parameter is table name, second is column name | ||
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.
In CSS - we separate multiple-named styles with the
-
rather than_