Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -161,7 +160,6 @@ PLATFORMS

DEPENDENCIES
byebug
cancancan (~> 1.10)
coffee-rails (~> 4.1.0)
devise
jbuilder (~> 2.0)
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= csrf_meta_tags %>
</head>
<body>

<!-- I really like your comments here. They make it easy to tell what I'm looking at. -->
<!-- Nav Bar -->
<div class="bar element">

Expand All @@ -32,7 +32,7 @@
<% end %>

</div>

<!-- Body -->
<div class="container">

Expand Down
19 changes: 10 additions & 9 deletions app/views/posts/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<!-- beautified -->
<div class="container">
<div class="post">
<%= form_for @post do |f| %>
<%= f.label :title, class: "form_title" %>
<%= f.text_area :title, class: "form_title"%>
<div class="post">
<%= 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 %>
</div>
<%= f.submit %>
<% end %>
</div>
</div>
9 changes: 5 additions & 4 deletions app/views/posts/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!-- beautified -->
<div class="container">
<h1>Edit Post</h1>
<h1>Edit Post</h1>

<%= 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 %>

</div>
67 changes: 36 additions & 31 deletions app/views/posts/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
<!-- beautified -->
<div class="container">
<div class="title post element">
<%= link_to 'New Post', new_post_path(@post) %>
</div>
<% @posts.each do |post| %>
<div class="post">
<div class="title element">

<div class="create"><%= post.user.email %> said: </div><%= post.title %>
</div>
<div class="body">
<%= post.body%>

</div>

<% post.comments.each do |comment| %>
<div class="comments">
<%= comment.user.email + " said : "%><%= comment.content %><%= link_to 'X', post_comments_path(comment), method: :delete %><br>
</div>

<% end %>
<div class="body">

<%= form_for([post, @comment]) do |f| %>
<div class="flex">
<%= f.text_field :content %>
<%= f.submit 'Comment', class: 'button element' %>
</div>
<div class="title post element">
<%= link_to 'New Post', new_post_path(@post) %>
</div>
<% @posts.each do |post| %>
<div class="post">
<div class="title element">
<!-- The below line was throwing an error: NoMethodError in Posts#index
Showing /Users/BryceLively/wdi/sandbox/project_two-1/app/views/posts/index.html.erb where line #9 raised:

undefined method `email' for nil:NilClass -->
<div class="create"><%= post.user.email %>
said:
</div><%= post.title %>
</div>
<div class="body">
<%= post.body%>

</div>

<% post.comments.each do |comment| %>
<div class="comments">
<%= comment.user.email + " said : "%><%= comment.content %><%= link_to 'X', post_comments_path(comment), method: :delete %><br>
</div>

<% end %>
<div class="body">

<%= link_to 'Edit Post', edit_post_path(post)%>
</div>
</div>
<%= form_for([post, @comment]) do |f| %>
<div class="flex">
<%= f.text_field :content %>
<%= f.submit 'Comment', class: 'button element' %>
</div>
<% end %>

<% end %>
<%= link_to 'Edit Post', edit_post_path(post)%>
</div>
</div>

<% end %>

</div>
5 changes: 3 additions & 2 deletions app/views/posts/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- beautified -->
<div class="container">
<%= render'form' %>
<%= link_to 'back', posts_path %>
<%= render'form' %>
<%= link_to 'back', posts_path %>
</div>
23 changes: 12 additions & 11 deletions app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<!-- beautified -->
<div class="container">
<div class="post">
<div class="title element">
<%= @post.title %>
</div>
<div class="body">
<%= @post.body %>
</div>
<%= link_to 'Edit Post', edit_post_path(@post)%>
<%= link_to 'Destroy', post_path(@post),
<div class="post">
<div class="title element">
<%= @post.title %>
</div>
<div class="body">
<%= @post.body %>
</div>
<%= link_to 'Edit Post', edit_post_path(@post)%>
<%= link_to 'Destroy', post_path(@post),
method: :delete,
data: { confirm: 'Are you sure?' } %>
</div>
<%= link_to 'Back to Posts', posts_path %>
</div>
<%= link_to 'Back to Posts', posts_path %>
</div>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down