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

Water - Mackenzie #31

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7bc37a
Initial Rails setup
mvlofthus Nov 10, 2020
5e963e2
database seeded, beginning Work model and controller setup
mvlofthus Nov 11, 2020
b01fdf1
Work index - basic with ul and brute forced organization by category
mvlofthus Nov 11, 2020
7f9c83e
made homepage controller, started other roots
mvlofthus Nov 11, 2020
1bbd726
shifted homepage to custom method under works, homepage displays samp…
mvlofthus Nov 11, 2020
4476c9d
correcting seeds.rb file, mislabeled one column, and publication year…
mvlofthus Nov 11, 2020
8dcb6cb
work show page created, links on index and home page, starting to mak…
mvlofthus Nov 12, 2020
ee4025d
work new, partial form, create, validate uniqueness of title (but not…
mvlofthus Nov 12, 2020
6cdd24b
work: edit and update, destroy, started some button CSS
mvlofthus Nov 12, 2020
44c77d0
work_test passes: can be instantiated, will have required fields, val…
mvlofthus Nov 12, 2020
44ac06a
work_test: unique title test passes
mvlofthus Nov 12, 2020
6c74b58
added flash messages for success and failure
mvlofthus Nov 12, 2020
56223da
added 2 controller tests for custom homepage method. Will update tes…
mvlofthus Nov 12, 2020
adcaf9c
set up user and votes, relationships, user CRUD and views. Something…
mvlofthus Nov 13, 2020
b6b8cc3
custom routes and methods for user. login and log out buttons work
mvlofthus Nov 13, 2020
c2355ec
votes displaying on all show pages and indexes, need to convert to ta…
mvlofthus Nov 13, 2020
0509994
worked through db seeding, calling custom methods in controller
mvlofthus Nov 14, 2020
4422d07
spotlight work custom helper method and on homepage
mvlofthus Nov 14, 2020
4c3ef88
forgot to make new branch, adding changes to prevent any issues
mvlofthus Nov 14, 2020
48ec98e
corrected upvote to be consistent as a nested route (under votes cont…
mvlofthus Nov 14, 2020
17ea2dc
upvote functionality works, unique user requirement works
mvlofthus Nov 14, 2020
f64351c
sort works by rating on index
mvlofthus Nov 14, 2020
1b5f4fb
user model tests pass, issues with user controller tests. will come …
mvlofthus Nov 15, 2020
a034266
got yml objects to talk to eachother, had to assign IDs to each
mvlofthus Nov 15, 2020
f38565e
all model tests work, all validations tested
mvlofthus Nov 15, 2020
4799b2a
added in testing for relations between models
mvlofthus Nov 15, 2020
5614ca8
missed category uniquness for works, added in and added testing
mvlofthus Nov 15, 2020
03e0bbe
starting bootstrap class names
mvlofthus Nov 16, 2020
2e66c90
added table to index page, updated to use bootstrap: buttons, header,…
mvlofthus Nov 16, 2020
17ed3bc
corrected old test, no longer works with yml file
mvlofthus Nov 16, 2020
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
work: edit and update, destroy, started some button CSS
mvlofthus committed Nov 12, 2020
commit 6cdd24b1efb237806c6f4fc8b1069e716e2089d9
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -16,3 +16,8 @@
@import "bootstrap";

@import "**/*";

.delete_button {
background-color: red;
border-radius: 6px;
}
39 changes: 39 additions & 0 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
@@ -28,6 +28,45 @@ def create
end
end

def edit
@work = Work.find_by(id: params[:id])

if @work.nil?
redirect_to works_path
return
end
end

def update
@work = Work.find_by(id: params[:id])

if @work.nil?
head :not_found
return
elsif @work.update(work_params)
redirect_to work_path(@work.id)
return
else # save failed :(
render :edit, status: :bad_request
return
end
end

def destroy
@work = Work.find_by(id: params[:id])

if @work.nil?
redirect_to works_path, head: :temporary_redirect
return
end


@work.destroy

redirect_to works_path
return
end

def homepage
@works = Work.all
@spotlight = Work.all.sample(1)[0]
11 changes: 11 additions & 0 deletions app/views/works/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h2>Edit this <%= @work.category.titleize %></h2>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

titleize!


<% if @work.errors.any? %>
<ul class="errors">
<% @work.errors.each do |column, message| %>
<li><strong><%= column %></strong> <%= message %></li>
<% end %>
</ul>
<% end %>

<%= render partial: "form", locals: { action_name: "Edit" } %>
7 changes: 6 additions & 1 deletion app/views/works/show.html.erb
Original file line number Diff line number Diff line change
@@ -5,4 +5,9 @@
<p> <%= @work.description %></p>


<%= button_to "Back to media ranks", root_path, method: :get %>
<section>
<%= button_to "Back to media ranks", root_path, method: :get, form: {style: 'display:inline-block;'} %>
<%= button_to "Edit", edit_work_path, method: :get, form: {style: 'display:inline-block;'} %>
placeholder for upvote
<%= button_to "Delete", work_path(@work.id), method: :delete, form: {style: 'display:inline-block;'}, class: 'delete_button', data: { confirm: "Are you sure you want to delete this driver?" } %>
</section>