Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
74 changes: 38 additions & 36 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
source 'https://rubygems.org'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.3'
ruby "3.0.3"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.3', '>= 6.1.3.1'
gem "rails", "~> 6.1.3", ">= 6.1.3.1"
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.1'
gem "pg", "~> 1.1"
# Use Puma as the app server
gem 'puma', '~> 5.0'
gem "puma", "~> 5.0"
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
gem "sass-rails", ">= 6"
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
gem "webpacker", "~> 5.0"
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
gem "turbolinks", "~> 5"
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
gem "jbuilder", "~> 2.7"
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
Expand All @@ -26,52 +26,54 @@ gem 'jbuilder', '~> 2.7'
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
gem "bootsnap", ">= 1.4.4", require: false

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
gem "web-console", ">= 4.1.0"
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
gem "rack-mini-profiler", "~> 2.0"
gem "listen", "~> 3.3"
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem "spring"
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
gem "capybara", ">= 3.26"
gem "selenium-webdriver"
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
gem "webdrivers"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# appdev Gems
group :development do
gem 'annotate'
gem 'awesome_print'
gem 'better_errors'
gem 'binding_of_caller'
gem 'bullet'
gem 'htmlbeautifier'
gem 'pry-rails'
gem 'rack-canonical-host'
gem 'rails-erd'
gem 'rollbar'
gem 'rufo'
gem 'standard', require: false
gem 'solargraph'
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
gem 'skylight'
gem 'web_git', github: 'firstdraft/web_git'
gem "faker", "~> 3.1"
gem "devise", "~> 4.8", ">= 4.8.1"
gem "annotate", "~> 3.2"
gem "awesome_print"
gem "better_errors"
gem "binding_of_caller"
gem "bullet"
gem "htmlbeautifier"
gem "pry-rails"
gem "rack-canonical-host"
gem "rails-erd"
gem "rollbar"
gem "rufo"
gem "standard", require: false
gem "solargraph"
gem "rubocop-rails", require: false
gem "rubocop-rspec", require: false
gem "skylight"
gem "web_git", github: "firstdraft/web_git"
end
21 changes: 18 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ GEM
ast (2.4.2)
awesome_print (1.9.2)
backport (1.2.0)
bcrypt (3.1.18)
benchmark (0.2.0)
better_errors (2.9.1)
coderay (>= 1.0.0)
Expand Down Expand Up @@ -111,10 +112,18 @@ GEM
concurrent-ruby (1.1.10)
crass (1.0.6)
debug_inspector (1.1.0)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.0)
diffy (3.4.2)
e2mmap (0.1.0)
erubi (1.11.0)
faker (3.1.0)
i18n (>= 1.8.11, < 2)
ffi (1.15.5)
git (1.12.0)
addressable (~> 2.8)
Expand Down Expand Up @@ -153,8 +162,7 @@ GEM
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.9-x86_64-darwin)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.22.1)
parser (3.1.1.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -218,6 +226,9 @@ GEM
ffi (~> 1.0)
rchardet (1.8.0)
regexp_parser (2.2.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
reverse_markdown (2.1.1)
nokogiri
rexml (3.2.5)
Expand Down Expand Up @@ -307,6 +318,8 @@ GEM
tzinfo (>= 1.0.0)
unicode-display_width (2.1.0)
uniform_notifier (1.16.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -336,14 +349,16 @@ PLATFORMS
x86_64-darwin-19

DEPENDENCIES
annotate
annotate (~> 3.2)
awesome_print
better_errors
binding_of_caller
bootsnap (>= 1.4.4)
bullet
byebug
capybara (>= 3.26)
devise (~> 4.8, >= 4.8.1)
faker (~> 3.1)
htmlbeautifier
jbuilder (~> 2.7)
listen (~> 3.3)
Expand Down
65 changes: 65 additions & 0 deletions app/assets/stylesheets/scaffolds.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
body {
background-color: #fff;
color: #333;
margin: 33px; }

body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }

a {
color: #000; }

a:visited {
color: #666; }

a:hover {
color: #fff;
background-color: #000; }

th {
padding-bottom: 5px; }

td {
padding: 0 5px 7px; }

div.field,
div.actions {
margin-bottom: 10px; }

#notice {
color: green; }

.field_with_errors {
padding: 2px;
background-color: red;
display: table; }

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px 7px 0;
margin-bottom: 20px;
background-color: #f0f0f0; }

#error_explanation h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px -7px 0;
background-color: #c00;
color: #fff; }

#error_explanation ul li {
font-size: 12px;
list-style: square; }

label {
display: block; }
3 changes: 3 additions & 0 deletions app/assets/stylesheets/tasks.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the tasks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user!
end
104 changes: 104 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
class TasksController < ApplicationController
before_action :set_task, only: %i[ show edit update destroy move ]

def move
if @task.notstarted?
@task.pending!
elsif @task.pending?
@task.complete!
elsif @task.complete?
@task.pending!
end

respond_to do |format|
format.js do
render template: "tasks/move.js.erb"
end
end
end

# GET /tasks or /tasks.json
def index
@tasks = current_user.tasks
end

# GET /tasks/1 or /tasks/1.json
def show
end

# GET /tasks/new
def new
@task = Task.new
end

# GET /tasks/1/edit
def edit
respond_to do |format|
format.html
format.js do
render template: "tasks/edit.js.erb"
end
end
end

# POST /tasks or /tasks.json
def create
@task = current_user.tasks.new(task_params)

respond_to do |format|
if @task.save
format.html { redirect_to task_url(@task), notice: "Task was successfully created." }
format.json { render :show, status: :created, location: @task }
format.js do
render template: "tasks/create.js.erb"
end
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @task.errors, status: :unprocessable_entity }
format.js
end
end
end

# PATCH/PUT /tasks/1 or /tasks/1.json
def update
respond_to do |format|
if @task.update(task_params)
format.html { redirect_to task_url(@task), notice: "Task was successfully updated." }
format.json { render :show, status: :ok, location: @task }
format.js do
render template: "tasks/update.js.erb"
end
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @task.errors, status: :unprocessable_entity }
format.js
end
end
end

# DELETE /tasks/1 or /tasks/1.json
def destroy
@task.destroy

respond_to do |format|
format.html { redirect_to tasks_url, notice: "Task was successfully destroyed." }
format.json { head :no_content }
format.js do
render template: "tasks/destroy.js.erb"
end
end
end

private

# Use callbacks to share common setup or constraints between actions.
def set_task
@task = Task.find(params[:id])
end

# Only allow a list of trusted parameters through.
def task_params
params.require(:task).permit(:body, :status)
end
end
2 changes: 2 additions & 0 deletions app/helpers/tasks_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module TasksHelper
end
27 changes: 27 additions & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# == Schema Information
#
# Table name: tasks
#
# id :bigint not null, primary key
# body :text
# status :string default("notstarted")
# created_at :datetime not null
# updated_at :datetime not null
# owner_id :bigint not null
#
# Indexes
#
# index_tasks_on_owner_id (owner_id)
#
# Foreign Keys
#
# fk_rails_... (owner_id => users.id)
#
class Task < ApplicationRecord
belongs_to :owner, class_name: "User"
enum status: { notstarted: "notstarted", pending: "pending", complete: "complete" }
scope :notstarted, -> { where(status: "notstarted") }
scope :pending, -> { where(status: "pending") }
scope :complete, -> { where(status: "complete") }
validates :body, presence: true
end
Loading