diff --git a/Gemfile b/Gemfile index 3b4d4e1..ec7c577 100644 --- a/Gemfile +++ b/Gemfile @@ -47,9 +47,11 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' - group :production do - gem 'rails_12factor' - end +end +# NHO: Make sure to move this group outside of the development group! +group :production do + gem 'rails_12factor' end - gem 'devise' + +gem 'devise' diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index dd4e97e..0000000 --- a/README.rdoc +++ /dev/null @@ -1,28 +0,0 @@ -== README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 4253b17..427f18d 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -13,11 +13,13 @@ def create end def edit + # NHO: How could we lock down these actions to protect users from editing other users comments? @post = Post.find(params[:id]) @comment = Comment.find(params[:id]) end def update + # NHO: How could we lock down these actions to protect users from editing other users comments? @comment = Comment.find(params[:id]) @comment.update(comment_params.merge(user:current_user)) redirect_to posts_path diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 4d39672..67b2328 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,14 +1,14 @@ class PostsController < ApplicationController - load_and_authorize_resource + load_and_authorize_resource # NHO: This helper can be utilized to DRY up our controller code, let's take advantage! def index - @posts = Post.order('updated_at DESC').all - @post = Post.where(params[:id]) + @posts = Post.order('updated_at DESC') # NHO: this works! Have also seen. Post.all.order('updated_at DESC') + @post = Post.where(params[:id]) # NHO: I think we want `Post.find` to grab the one post here. @comment = Comment.new end def show - @post = Post.find(params[:id]) + @post = Post.find(params[:id]) # NHO: Line no longer necessary because of load part of load_and_authorize_resource, same with edit, update, destroy end def new diff --git a/app/models/ability.rb b/app/models/ability.rb index c8d68c9..d75e072 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -5,7 +5,7 @@ def initialize(user) can :read, Post if user can :create, Post - can [:update, :destroy], Post, :user => user + can [:update, :destroy], Post, :user => user # NHO: How could we implement the same rules for comments as well? end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 7435d55..09285c2 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,6 +1,7 @@ class Comment < ActiveRecord::Base belongs_to :user belongs_to :post + # Nice validations! validates :content, presence: true, length: { minimum: 1 } end diff --git a/app/models/post.rb b/app/models/post.rb index f404d3e..5a006f5 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,4 +1,4 @@ class Post < ActiveRecord::Base belongs_to :user - has_many :comments, dependent: :destroy + has_many :comments, dependent: :destroy # NHO: great use of dependent destroy end diff --git a/app/views/comments/_new.html.erb b/app/views/comments/_new.html.erb index 4dc07a0..31ac4a6 100644 --- a/app/views/comments/_new.html.erb +++ b/app/views/comments/_new.html.erb @@ -5,3 +5,5 @@ <%= f.submit %> <% end %> + + diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index f678cac..1879c6f 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -1,16 +1,17 @@
-<%= form_for @post do |f| %> - <%= f.label :title, class: "form_title" %> - <%= f.text_area :title, class: "form_title"%> + <%= form_for @post do |f| %> + <%= f.label :title, class: "form_title" %> + <%= f.text_area :title, class: "form_title"%> - <%= f.label :body, class: "form_body" %> - <%= f.text_field :body, class: "form_body" %> + <%= f.label :body, class: "form_body" %> + <%= f.text_field :body, class: "form_body" %> - <%#= f.label :img_url, class: "form_body" %> - <%#= f.text_area :img_url, class: "form_body" %> + + <%#= f.label :img_url, class: "form_body" %> + <%#= f.text_area :img_url, class: "form_body" %> - <%= f.submit %> -<% end %> + <%= f.submit %> + <% end %>
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 2c7c68d..84d1ff6 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -1,43 +1,45 @@ +
-
-<%= link_to 'New Post', new_post_path(@post) %> -
- -<% @posts.each do |post| %> -
-
- -
<%= post.user.email %> said:
<%= post.title %> +
+ <%= link_to 'New Post', new_post_path(@post) %>
-
- - <%#= image_tag post.img_url %> - - <%= post.body%> -
+ <% @posts.each do |post| %> +
+
+
<%= post.user.email %> + said: +
<%= post.title %> +
+
- <% post.comments.each do |comment| %> -
- <%= comment.user.email + " said : "%><%= comment.content + " "%><%= link_to 'Edit', edit_post_comment_path(post, comment) %>
-
+ <%#= image_tag post.img_url %> - <% end %> -
+ <%= post.body%> - <%= form_for([post, @comment]) do |f| %> -
- <%= f.text_field :content %> - <%= f.submit 'Comment', class: 'button element' %>
- <% end %> - <% if can? :update, post %> - <%= link_to 'Edit Post', edit_post_path(post)%> - <% end %> -
-
-<% end %> + <% post.comments.each do |comment| %> +
+ + <%= comment.user.email + " said : "%><%= comment.content + " "%><%= link_to 'Edit', edit_post_comment_path(post, comment) %>
+
+ <% end %> +
+ <%= form_for([post, @comment]) do |f| %> +
+ <%= f.text_field :content %> + <%= f.submit 'Comment', class: 'button element' %> +
+ <% end %> + + <% if can? :update, post %> + <%= link_to 'Edit Post', edit_post_path(post)%> + <% end %> +
+
+ <% end %>
+ diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index c61d64d..c703e78 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -7,10 +7,9 @@ <%= image_tag @post.img_url %> <%= @post.body %>
+ <%= link_to 'Edit Post', edit_post_path(@post)%> - <%= link_to 'Destroy', post_path(@post), - method: :delete, - data: { confirm: 'Are you sure?' } %> + <%= link_to 'Destroy', post_path(@post), method: :delete, data: { confirm: 'Are you sure?' } %>
<%= link_to 'Back to Posts', posts_path %> diff --git a/config/routes.rb b/config/routes.rb index f66319a..689ae2b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ root to: "posts#index" resources :posts do - resources :comments, except: [:index, :show] + resources :comments, except: [:index, :show] # NHO: doesnt look like you are using a destroy action either end end diff --git a/feedback_nho.md b/feedback_nho.md new file mode 100644 index 0000000..ae8bcba --- /dev/null +++ b/feedback_nho.md @@ -0,0 +1,34 @@ +# Feedback + +## Project Workflow + +**Exceeds Expectations** + +Great job with the planning process! Nice wirefames, and user stories are clear, and accomplishable! Would be really cool to see more commentary in your `readme` about your process, things you would like to implemnt! Also, please include set-up instructions for this application. + +## Technical Requirements + +**Meets Expectations** + +Nice job implementing user authentication, and locking down your app's authorization with CanCanCan! +Demonstrates utilizing nested resources, and at least two models of CRUD. + +## Creativity / Interface + +**Exceeds Expectations** + +Really enjoyed your approach with the visual design, and your creativity was evident in your CSS and layout! +Loved how most of the app's action occurs on the index page, would like to see you eventually turn this into a Single Page app via partials and/or front-end JS/ajax in the future! + +## Code Quality + +**Meets Expectations** + +Please review [inline code comments](https://github.com/brittonwalker/project_two/compare/master...nolds9:feedback) +prefixed with my initials: `NHO` for detailed feedback. + +## Deployment and Functionality + +**Meets Expectations** + +Great job hitting your MVP, app is functional, and deployed, though currently I think there might be an issue with the latest version last time I checked. Would like to see you challenge yourself to come back to this an tackle your gold user stories! Make sure to put the link to the deployed url in your repo.