From 9d5afc8bcc5c7a7edcc2b5f35b811c7d485ec8b7 Mon Sep 17 00:00:00 2001 From: Bryce Lively Date: Thu, 19 Nov 2015 16:49:25 -0500 Subject: [PATCH] comments and some beautification --- Gemfile | 5 +- Gemfile.lock | 2 - app/views/layouts/application.html.erb | 4 +- app/views/posts/_form.html.erb | 19 ++++---- app/views/posts/edit.html.erb | 9 ++-- app/views/posts/index.html.erb | 67 ++++++++++++++------------ app/views/posts/new.html.erb | 5 +- app/views/posts/show.html.erb | 23 ++++----- config/routes.rb | 1 + 9 files changed, 72 insertions(+), 63 deletions(-) diff --git a/Gemfile b/Gemfile index 4003bf7..a557f16 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ source 'https://rubygems.org' - -gem 'cancancan', '~> 1.10' +# Commenting out cancancan to see if that fixes the error. +# Doesn't look like that fixed the issue. But I also stupidly trusted the internet and deleted my gems. So IDK. +#gem 'cancancan', '~> 1.10' gem 'pry' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' diff --git a/Gemfile.lock b/Gemfile.lock index 998b08c..366683b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,7 +42,6 @@ GEM debug_inspector (>= 0.0.1) builder (3.2.2) byebug (8.2.0) - cancancan (1.13.1) coderay (1.1.0) coffee-rails (4.1.0) coffee-script (>= 2.2.0) @@ -161,7 +160,6 @@ PLATFORMS DEPENDENCIES byebug - cancancan (~> 1.10) coffee-rails (~> 4.1.0) devise jbuilder (~> 2.0) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b7d5b0b..85f886f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,7 +7,7 @@ <%= csrf_meta_tags %> - +
@@ -32,7 +32,7 @@ <% end %>
- +
diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index 88adc08..0e684dd 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -1,13 +1,14 @@ +
-
-<%= 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.submit %> -<% end %> -
+ <%= f.submit %> + <% end %> +
diff --git a/app/views/posts/edit.html.erb b/app/views/posts/edit.html.erb index 2477ee5..0331c50 100644 --- a/app/views/posts/edit.html.erb +++ b/app/views/posts/edit.html.erb @@ -1,10 +1,11 @@ +
-

Edit Post

+

Edit Post

- <%= render'form' %> - <%= link_to 'Destroy', post_path(@post), + <%= render'form' %> + <%= link_to 'Destroy', post_path(@post), method: :delete, data: { confirm: 'Are you sure?' } %> - <%= link_to 'back', root_path %> + <%= link_to 'back', root_path %>
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 33faf55..fc28847 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -1,38 +1,43 @@ +
-
-<%= link_to 'New Post', new_post_path(@post) %> -
-<% @posts.each do |post| %> -
-
- -
<%= post.user.email %> said:
<%= post.title %> -
-
- <%= post.body%> - -
- - <% post.comments.each do |comment| %> -
- <%= comment.user.email + " said : "%><%= comment.content %><%= link_to 'X', post_comments_path(comment), method: :delete %>
-
- - <% end %> -
- - <%= form_for([post, @comment]) do |f| %> -
- <%= f.text_field :content %> - <%= f.submit 'Comment', class: 'button element' %> -
+
+ <%= link_to 'New Post', new_post_path(@post) %> +
+ <% @posts.each do |post| %> +
+
+ +
<%= post.user.email %> + said: +
<%= post.title %> +
+
+ <%= post.body%> + +
+ + <% post.comments.each do |comment| %> +
+ <%= comment.user.email + " said : "%><%= comment.content %><%= link_to 'X', post_comments_path(comment), method: :delete %>
+
+ <% end %> +
- <%= link_to 'Edit Post', edit_post_path(post)%> -
-
+ <%= form_for([post, @comment]) do |f| %> +
+ <%= f.text_field :content %> + <%= f.submit 'Comment', class: 'button element' %> +
+ <% end %> -<% end %> + <%= link_to 'Edit Post', edit_post_path(post)%> +
+
+ <% end %>
diff --git a/app/views/posts/new.html.erb b/app/views/posts/new.html.erb index ca265c9..280db74 100644 --- a/app/views/posts/new.html.erb +++ b/app/views/posts/new.html.erb @@ -1,4 +1,5 @@ +
-<%= render'form' %> -<%= link_to 'back', posts_path %> + <%= render'form' %> + <%= link_to 'back', posts_path %>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 76c38ed..91b0f4a 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -1,15 +1,16 @@ +
-
-
- <%= @post.title %> -
-
- <%= @post.body %> -
- <%= link_to 'Edit Post', edit_post_path(@post)%> - <%= link_to 'Destroy', post_path(@post), +
+
+ <%= @post.title %> +
+
+ <%= @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 'Back to Posts', posts_path %> +
+ <%= link_to 'Back to Posts', posts_path %>
diff --git a/config/routes.rb b/config/routes.rb index f66319a..5ff8cf3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ devise_for :users root to: "posts#index" +# I like this, thanks for showing me. resources :posts do resources :comments, except: [:index, :show] end