Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class PostsController < ApplicationController
  2. def index
  3. end
  4.  
  5. def create
  6. @post = current_user.posts.build(post_params)
  7.  
  8. if @post.save
  9. flash[:success] = 'Post successful'
  10. redirect_to posts_path
  11. else
  12. flash[:danger] = 'Post unsuccessful'
  13. render 'users/show'
  14. end
  15. end
  16.  
  17. def destroy
  18.  
  19. end
  20.  
  21. private
  22.  
  23. def post_params
  24. params.require(:post).permit(:content)
  25. end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement