Skip to content

Commit f3526da

Browse files
committed
Finished with Wave1
1 parent c943bb8 commit f3526da

23 files changed

+1412
-0
lines changed

app/assets/javascripts/tasks.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/javascripts/welcome.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/tasks.css

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*// Place all the styles related to the Tasks controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/*/
4+
5+
6+
/*********************************************************
7+
HEADER
8+
**********************************************************/
9+
10+
#index_header {
11+
position: fixed;
12+
top: 100px;
13+
width: 100%;
14+
height: 50px;
15+
text-align: center;
16+
vertical-align: middle;
17+
background-color: black;
18+
color: white;
19+
}
20+
21+
#index_main{
22+
margin-top: 50px
23+
}
24+
25+
#index_main nav {
26+
display: inline-block;
27+
width: 50%;
28+
text-align: center;
29+
list-style-type: none;
30+
}
31+
32+
#index_main li {
33+
list-style-type: none;
34+
}
35+
36+
#index_main a {
37+
text-decoration: none;
38+
}

app/assets/stylesheets/welcome.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*// Place all the styles related to the Welcome controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/*/

app/controllers/tasks_controller.rb

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class TasksController < ApplicationController
2+
# TASKS = [{ name: "The First Task", description: "This is a description for the first task.", completed_at: "random_time "},
3+
# { name: "Go to Brunch", description: "This is a description for the brunch." },
4+
# { name: "Go to Lunch", description: "This is a description for the lunch.", completed_at: "random_time" },
5+
# { name: "Go to Second Lunch", description: "This is a description for the second lunch." },
6+
# { name: "Play Video Games", description: "This is a description for playing video games.", completed_at: "random_time "},
7+
# { name: "High Five Somebody You Don't Know", description: "This is a description for highfiving someone.", completed_at: "random_time" },
8+
# { name: "Plant Flowers", description: "This is a description for planting flowers.", completed_at: "random_time "},
9+
# { name: "Call Mom", description: "This is a description for playing video games." },
10+
# { name: "She worries, you know.", description: "This is a description for how to worry." },
11+
# { name: "Nap.", description: "This is a description for taking a nap.", completed_at: "random_time "}]
12+
13+
def index
14+
puts ">>>>>>amb<<<<<<<<: Inside tasks index!"
15+
@tasks = Task.all
16+
end
17+
18+
def show
19+
id = params[:id].to_i
20+
@task = Task.find(id)
21+
end
22+
end

app/controllers/welcome_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class WelcomeController < ApplicationController
2+
def index
3+
end
4+
end

app/helpers/tasks_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module TasksHelper
2+
end

app/helpers/welcome_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module WelcomeHelper
2+
end

app/models/task.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Task < ApplicationRecord
2+
end

app/views/layouts/application.html.erb

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
99
</head>
1010

11+
<header>
12+
<h1>This is the header in the application.html code</h1>
13+
</header>
14+
1115
<body>
1216
<%= yield %>
1317
</body>

app/views/tasks/index.html.erb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
<header id = "index_header">
3+
<h1>Tasks list</h1>
4+
</header>
5+
6+
7+
8+
9+
<main id = "index_main">
10+
<nav>
11+
<ul>
12+
<% @tasks.each_with_index do |task| %>
13+
<li>
14+
<%= link_to task[:name], task_path(task.id) %>
15+
</li>
16+
<% end %>
17+
</ul>
18+
</nav>
19+
20+
</main>
21+
22+
23+
24+
25+
26+
<!-- <% 10.times do %>
27+
<p>
28+
This will be there 10 times
29+
</p>
30+
<% end %> -->

app/views/tasks/show.html.erb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h1><%= @task[:name]%></h1>
2+
<p>
3+
Description: <%= @task[:description] %>
4+
</p>
5+
<p>
6+
<%= link_to "Back to books", tasks_path %>
7+
</p>

app/views/welcome/index.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<h1>Welcome!</h1>
2+
<p>
3+
This is the welcome page for the rails project TaskList.
4+
</p>
5+
6+
<div>
7+
<%=link_to "List of all tasks", tasks_path %>
8+
</div>

config/routes.rb

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
Rails.application.routes.draw do
22
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3+
root 'welcome#index', as: 'welcome'
4+
5+
get 'tasks', to: 'tasks#index', as: 'tasks' #The index always requires the controllers?????
6+
7+
8+
# get 'tasks/:id', to: 'tasks#show'
9+
10+
get 'tasks/:id', to: 'tasks#show', as: 'task'
11+
312
end

db/development.sqlite3

28 KB
Binary file not shown.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class CreateTasks < ActiveRecord::Migration[5.0]
2+
def change
3+
create_table :tasks do |t|
4+
t.string :name
5+
t.string :description
6+
7+
t.timestamps
8+
end
9+
end
10+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddCompletionDateColumnToTasksTable < ActiveRecord::Migration[5.0]
2+
def change
3+
add_column :tasks, :completion_date, :datetime
4+
end
5+
end

db/schema.rb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This file is auto-generated from the current state of the database. Instead
2+
# of editing this file, please use the migrations feature of Active Record to
3+
# incrementally modify your database, and then regenerate this schema definition.
4+
#
5+
# Note that this schema.rb definition is the authoritative source for your
6+
# database schema. If you need to create the application database on another
7+
# system, you should be using db:schema:load, not running all the migrations
8+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
9+
# you'll amass, the slower it'll run and the greater likelihood for issues).
10+
#
11+
# It's strongly recommended that you check this file into your version control system.
12+
13+
ActiveRecord::Schema.define(version: 20170321212217) do
14+
15+
create_table "tasks", force: :cascade do |t|
16+
t.string "name"
17+
t.string "description"
18+
t.datetime "created_at", null: false
19+
t.datetime "updated_at", null: false
20+
t.datetime "completion_date"
21+
end
22+
23+
end

0 commit comments

Comments
 (0)