You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everyone was so on top of it this week why don't we push through and finish the whole thing by next week. Then next week we can start a new one.
We will NOT be coding during the Meetup next time so be sure to finish before then. If you have any questions pose them in the google group.
Do the work for 10-16 in the videos.
10. Add Validation to Blog Posts 11. Edit and Delete Blog Posts 12. Add Comments to Blog Posts 13. Deleting Comments on Blog Posts 14. About Page -- Static Pages and Profile Picture 15. Add Users to Blog, Limit Options to Non-Users 16. Finish Blog App
Update your app/views/comments/_comment.html.erb so you can delete a comment
<divclass="comment clearfix">
<divclass="comment_content">
<pclass="comment_name"><strong><%= comment.name%></ strong></p> <p class="comment_body"><%= comment.body %></p>
<pclass="comment_time"><%= time_ago_in_words(comment.created_at) %>Ago</p> </div>
<p><%= link_to'Delete',[comment.post,comment],method: delete,class: "button",data: {confirm: 'Are you sure you want to delete your comment?'}%> </p>
</div>
#14. About Page -- Static Pages and Profile Picture
Update your app/models/post.rb to include dependent: :destroy to make sure that when the post is deleted that all the associated comments are also deleted
Go to Ruby on Rails in 3 Weeks
Everyone was so on top of it this week why don't we push through and finish the whole thing by next week. Then next week we can start a new one.
We will NOT be coding during the Meetup next time so be sure to finish before then. If you have any questions pose them in the google group.
Do the work for 10-16 in the videos.
10. Add Validation to Blog Posts
11. Edit and Delete Blog Posts
12. Add Comments to Blog Posts
13. Deleting Comments on Blog Posts
14. About Page -- Static Pages and Profile Picture
15. Add Users to Blog, Limit Options to Non-Users
16. Finish Blog App
The repository of the code
The directions from the video are written below.
Remember: $ means type this command in your terminal. Don't type it in. :)
+ Means add this code here. Don't type it in. :)
#10. Add Validation to Blog Posts
app/models/post.rb
app/controllers/posts_controller.rb
app/views/posts/new.html.erb
#11. Edit and Delete Blog Posts
app/controllers/posts_controller.rb
Create a new file called
app/views/posts/_form.html.erb
app/views/posts/new.html.erb
app/views/posts/new.html.erb
and thenapp/views/posts/_form.html.erb
fileChange the first line in the
app/views/posts/_form.html.erb
fileChange your
app/views/posts/new.html.erb
to look like thisCreate a new file called
app/views/posts/edit.html.erb
Update your
app/views/posts/show.html.erb
to add a link to be able to edit your postUpdate your
app/controllers/posts_controller.rb
to add a the action to be able to delete your postUpdate your
app/views/posts/show.html.erb
to add a link to be able to delete your post#12. Add Comments to Blog Posts
Add a new Model called Comment so you can comment on your blog posts
$ rails g model Comment name:string body:string post:references
$ rake db:migrate
Add
has_many :comments
to theapp/models/post.rb
file to associate the post with the commentsUpdate your
config/routes.rb
file to add a link to nest the Comments into the PostsCreate the Comments Controller
$ rails g controller Comments
Update your new Comments Controller
app/controller/comment_controller.rb
to add a create actionCreate
app/views/comments/_form.html.erb
Create
app/views/comments/_comment.html.erb
Update
app/views/posts/show.html.erb
#13. Deleting Comments on Blog Posts
Update your Comments Controller
app/controller/comment_controller.rb
to add a delete actionUpdate your
app/views/comments/_comment.html.erb
so you can delete a comment#14. About Page -- Static Pages and Profile Picture
Update your
app/models/post.rb
to includedependent: :destroy
to make sure that when the post is deleted that all the associated comments are also deletedCreate a Pages Controller
$ rails g controller pages
In your new
app/controller/pages_controller.rb
add an about actionUpdate your
config/routes.rb
file to add a link to the About PageUpdate your
app/views/layouts/application.html.erb
Create
app/views/pages/about.html.erb
Add an image called
profile.jpg
inapp/assets/images
#15. Add Users to Blog, Limit Options to Non-Users
Get the most recent version of the Devise Gem and Add it to your Gemfile
Bundle your
Gemfile
$ bundle
Re-Start your server
$ rails g devise:install
Add this line to the bottom of your
config/environments/development.rb
Wrap the
app/view/devise/sessions/new.html.erb
in<div id="page_wrapper"> code</div>
Add a before_action to your
app/controller/post_controller.rb
Add some authentication to
app/views/layouts/application.html.erb
using Devise methodsUpdate your
app/views/posts/show.html.erb
to only allowe a signed in user to be able to delete or edit a postUpdate your
app/views/comments/_comment.html.erb
to only allow a signed in user to be able to delete or edit a post#16. Finish Blog App
You are finished! :)
Add more functionality
Add Tests
Or just move on to the Pinterest App
The text was updated successfully, but these errors were encountered: