Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class TasksController < ApplicationController
def index
if @mytask.user_id != session[:user_id]
flash[:notice] = "You cannot view a task list that is not your own."
redirect_to homepage_path
end
@tasks = Task.where(user_id: session[:user_id])
@user = User.find(session[:user_id])
end
Expand All @@ -10,6 +14,10 @@ def new

def show
@mytask = Task.find(params[:id].to_i)
if @mytask.user_id != session[:user_id]
flash[:notice] = "You cannot view or edit tasks that are not your own."
redirect_to homepage_path
end
end

def delete
Expand All @@ -33,6 +41,10 @@ def update
end

def create
if session[:user_id] = nil
flash[:notice] = "You must be logged in to create a task."
redirect_to homepage_path
end
@params = params
@mytask = Task.new
@mytask.task_name = params[:task][:task_name]
Expand Down
1 change: 1 addition & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Task < ActiveRecord::Base
belongs_to :user
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class User < ActiveRecord::Base
has_many :tasks
validates :email, :uid, :provider, presence: true

def self.build_from_github(auth_hash)
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

get "/auth/:provider/callback" => "sessions#create"

get 'homepages/index'
get 'homepages/index', as: 'homepage'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
Expand Down