From 0f04ec9da6b0db396d57d70fd2ab7ef6b5fea082 Mon Sep 17 00:00:00 2001 From: Perry Fustero Date: Thu, 14 Dec 2017 20:50:46 -0500 Subject: [PATCH 1/2] added comments --- README.md | 8 ++++++-- .../app/controllers/categories_controller.rb | 12 +++++++----- .../app/controllers/comments_controller.rb | 6 ++++-- .../app/controllers/vehicles_controller.rb | 4 ++-- Wheeled-Rider/app/models/category.rb | 2 +- .../app/views/categories/index.html.erb | 2 +- Wheeled-Rider/app/views/categories/show.html.erb | 4 ++-- Wheeled-Rider/app/views/comments/edit.html.erb | 1 - .../app/views/layouts/application.html.erb | 2 +- Wheeled-Rider/app/views/vehicles/_form.html.erb | 2 ++ Wheeled-Rider/app/views/vehicles/edit.html.erb | 1 - Wheeled-Rider/app/views/vehicles/index.html.erb | 8 +++++--- Wheeled-Rider/app/views/vehicles/show.html.erb | 11 ++++------- Wheeled-Rider/config/routes.rb | 16 +++++++--------- .../migrate/20171128150511_create_categories.rb | 3 +++ Wheeled-Rider/db/seeds.rb | 4 +++- 16 files changed, 48 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index c3dc258..c9239fa 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,12 @@ To participate, simply make an account, click on a vehicle image, and begin post ### Brief Example -Here's a sample snapshot: +Here's a sample snapshot: ![Wheeled Rider](https://i.imgur.com/l2T6Vg0.jpg) ### User Stories -Users are able to log into the site, choose (or make) a vehicle, select a representative image, and post a conntroversial opinion about their vehicle of choice. +Users are able to log into the site, choose (or make) a vehicle, select a representative image, and post a controversial opinion about their vehicle of choice. ### Technologies used * Ruby @@ -24,3 +24,7 @@ Users are able to log into the site, choose (or make) a vehicle, select a repres https://wheeled-rider.herokuapp.com/ screencast: https://www.youtube.com/watch?v=PQbhtj6e7KQ&feature=youtu.be + + + + diff --git a/Wheeled-Rider/app/controllers/categories_controller.rb b/Wheeled-Rider/app/controllers/categories_controller.rb index 1b185d4..6e787e1 100644 --- a/Wheeled-Rider/app/controllers/categories_controller.rb +++ b/Wheeled-Rider/app/controllers/categories_controller.rb @@ -12,8 +12,8 @@ def new # create def create @category = Category.create(category_params.merge(user: current_user)) - - @category.save + # Nice job using the merge method + @category.save # you don't need .save if you call .create redirect_to @category end @@ -24,7 +24,7 @@ def show # edit def edit - # @vehicle = Vehicle.find(params[:vehicle_id]) + # @vehicle = Vehicle.find(params[:vehicle_id]) # No commented out code in production! @category = Category.find(params[:id]) end @@ -39,11 +39,13 @@ def update def destroy @category = Category.find(params[:id]) @category.destroy - redirect_to "/vehicles/" + redirect_to "/vehicles" end private def category_params params.require(:category).permit(:title, :author, :num_replies, :last_reply, :vehicle) - end + end # Nice job using params.require in a private method end + +# Dont really need the comments for the methods names here diff --git a/Wheeled-Rider/app/controllers/comments_controller.rb b/Wheeled-Rider/app/controllers/comments_controller.rb index cc82947..d5922f6 100644 --- a/Wheeled-Rider/app/controllers/comments_controller.rb +++ b/Wheeled-Rider/app/controllers/comments_controller.rb @@ -2,7 +2,7 @@ class CommentsController < ApplicationController # index def index @comments = Comment.all - end + end # You can get rid of your index method and index views since its not being used. # new def new @@ -33,7 +33,7 @@ def edit # update def update - @comment = category.find(params[:id]) + @comment = Category.find(params[:id]) @comment.update(comment_params) redirect_to @comment end @@ -50,3 +50,5 @@ def comment_params params.require(:comment).permit(:contet, :author, :tier_of_reply, :time_posted, :category) end end + +# Delete commented method names diff --git a/Wheeled-Rider/app/controllers/vehicles_controller.rb b/Wheeled-Rider/app/controllers/vehicles_controller.rb index 5b01d81..d99a2e2 100644 --- a/Wheeled-Rider/app/controllers/vehicles_controller.rb +++ b/Wheeled-Rider/app/controllers/vehicles_controller.rb @@ -17,7 +17,7 @@ def create def show @vehicle = Vehicle.find(params[:id]) @categories = Category.where(vehicle_id: params[:id]) - # @categories = Category.all + # ^ This seems a little strange. You should be able to do @vehicle.categories to get all categories under a vehicle end def edit @@ -33,7 +33,7 @@ def update def destroy @vehicle = Vehicle.find(params[:id]) @vehicle.destroy - redirect_to "/vehicles/" + redirect_to "/vehicles" end private diff --git a/Wheeled-Rider/app/models/category.rb b/Wheeled-Rider/app/models/category.rb index 7fbf72d..84b1f47 100644 --- a/Wheeled-Rider/app/models/category.rb +++ b/Wheeled-Rider/app/models/category.rb @@ -1,4 +1,4 @@ class Category < ApplicationRecord - belongs_to :vehicle + belongs_to :vehicle # should also belong to users the way you have it mapped out. has_many :comments end diff --git a/Wheeled-Rider/app/views/categories/index.html.erb b/Wheeled-Rider/app/views/categories/index.html.erb index 3d16044..45bcf18 100644 --- a/Wheeled-Rider/app/views/categories/index.html.erb +++ b/Wheeled-Rider/app/views/categories/index.html.erb @@ -6,6 +6,6 @@
  • <%= link_to category.title, category_path(category) %>
  • -
    +
    <% end %> diff --git a/Wheeled-Rider/app/views/categories/show.html.erb b/Wheeled-Rider/app/views/categories/show.html.erb index 79f6c47..155b9d3 100644 --- a/Wheeled-Rider/app/views/categories/show.html.erb +++ b/Wheeled-Rider/app/views/categories/show.html.erb @@ -1,7 +1,7 @@

    <%= @category.title %>

    - +
  • (go back)
  • Reply to post
  • (edit category)
  • @@ -10,7 +10,7 @@ diff --git a/Wheeled-Rider/app/views/comments/edit.html.erb b/Wheeled-Rider/app/views/comments/edit.html.erb index ec40c74..6ba812c 100644 --- a/Wheeled-Rider/app/views/comments/edit.html.erb +++ b/Wheeled-Rider/app/views/comments/edit.html.erb @@ -1,6 +1,5 @@

    Edit Your Comment

    - <%= render 'form' %> <%= link_to 'Delete!', comment_path(@comment), method: :delete, class: 'delete' %> diff --git a/Wheeled-Rider/app/views/layouts/application.html.erb b/Wheeled-Rider/app/views/layouts/application.html.erb index 035999b..2edaf3b 100644 --- a/Wheeled-Rider/app/views/layouts/application.html.erb +++ b/Wheeled-Rider/app/views/layouts/application.html.erb @@ -19,7 +19,7 @@ <%= link_to 'Login', new_user_session_path %> <% end %> - + <%= yield %> diff --git a/Wheeled-Rider/app/views/vehicles/_form.html.erb b/Wheeled-Rider/app/views/vehicles/_form.html.erb index e1a8af7..e66a289 100644 --- a/Wheeled-Rider/app/views/vehicles/_form.html.erb +++ b/Wheeled-Rider/app/views/vehicles/_form.html.erb @@ -9,3 +9,5 @@ <%= f.submit %> <% end %> + + diff --git a/Wheeled-Rider/app/views/vehicles/edit.html.erb b/Wheeled-Rider/app/views/vehicles/edit.html.erb index c14d6ba..39ca738 100644 --- a/Wheeled-Rider/app/views/vehicles/edit.html.erb +++ b/Wheeled-Rider/app/views/vehicles/edit.html.erb @@ -1,6 +1,5 @@

    Edit Vehicle

    - <%= render 'form' %> <%= link_to 'Delete!', vehicle_path(@vehicle), method: :delete, class: 'delete' %> diff --git a/Wheeled-Rider/app/views/vehicles/index.html.erb b/Wheeled-Rider/app/views/vehicles/index.html.erb index e86e5d2..b59517a 100644 --- a/Wheeled-Rider/app/views/vehicles/index.html.erb +++ b/Wheeled-Rider/app/views/vehicles/index.html.erb @@ -1,17 +1,19 @@

    Welcome to Wheeled Rider!!!

    -

    A forum for enthusiasts of ALL vehicles on wheels

    (click here if there's a vehicle you want, but dont see)
    +

    A forum for enthusiasts of ALL vehicles on wheels

    +

    (click here if there's a vehicle you want, but dont see)
    +
    - +
    <% @vehicles.each do |vehicle| %> <% end %> diff --git a/Wheeled-Rider/app/views/vehicles/show.html.erb b/Wheeled-Rider/app/views/vehicles/show.html.erb index f778cd6..13e117c 100644 --- a/Wheeled-Rider/app/views/vehicles/show.html.erb +++ b/Wheeled-Rider/app/views/vehicles/show.html.erb @@ -1,11 +1,8 @@ - +

    <%= @vehicle.name %>

    Edit page
    - -