Skip to content
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

Queues - Sofia Kim - TaskList #45

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added a button
Sofia15 committed Mar 24, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 4061fcfcf953e3d9619d3005c10576502cd9dc5f
8 changes: 8 additions & 0 deletions app/assets/stylesheets/tasks.css
Original file line number Diff line number Diff line change
@@ -13,3 +13,11 @@ h1 {
h1 {
border: 1px solid red;
}

.task_marked li a {
display: inline-block;
}

.task_marked li form {
display: inline-block;
}
9 changes: 5 additions & 4 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
@@ -33,9 +33,9 @@ def edit #link will still go to the show, but need a separate page
end

def update #patch request doesn't need view only Get request needs view
@task = Task.find(params[:id])
if @task.update({:name=>params[:task][:name], :description=>params[:task][:description]})
redirect_to task_path(@task.id)
task = Task.find(params[:id])
if task.update({:name=>params[:task][:name], :description=>params[:task][:description]})
redirect_to task_path(task.id)
else
render :edit #render to edit page
end
@@ -44,7 +44,8 @@ def update #patch request doesn't need view only Get request needs view
def mark_complete
@task = Task.find(params[:id])
@task.update({:completed_at=>Time.now})
redirect_to task_path(@task.id)
# redirect_to task_path(@task.id)
redirect_to tasks_path
end

end
4 changes: 3 additions & 1 deletion app/views/tasks/index.html.erb
Original file line number Diff line number Diff line change
@@ -2,10 +2,12 @@
<%= link_to "Create a new task", new_task_path %>

<div>
<ul>
<ul class="task_marked">
<% @tasks.each do |task| %>
<li>
<%= link_to task[:name], task_path(task.id) %>
<%= button_to "completed_at", "/tasks/#{task.id}/mark_complete" %>

</li>

<% end %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -15,4 +15,6 @@
resources :tasks

patch 'tasks/:id/mark_complete', to: 'tasks#mark_complete'

post 'tasks/:id/mark_complete', to: 'tasks#mark_complete'
end
Binary file modified db/development.sqlite3
Binary file not shown.
4 changes: 4 additions & 0 deletions db/migrate/20170322160753_add_pub_date_to_books.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class AddPubDateToBooks < ActiveRecord::Migration[5.0]
def change
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170321201815) do
ActiveRecord::Schema.define(version: 20170322160753) do

create_table "tasks", force: :cascade do |t|
t.string "name"
Binary file added db/test.sqlite3
Binary file not shown.
3,340 changes: 3,340 additions & 0 deletions log/development.log

Large diffs are not rendered by default.