Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class PostsController < ApplicationController
  2.  
  3. def update
  4. @post = Post.find(params[:id])
  5.  
  6. if @post.update(params[:post].permit(:title, :text))
  7. redirect_to @post
  8. else
  9. render 'edit'
  10. end
  11. end
  12.  
  13. def destroy
  14. @post = Post.find(params[:id])
  15. @post.destroy
  16.  
  17. redirect_to display_posts_path
  18. end
  19.  
  20. private
  21.  
  22. def post_params
  23. params.require(:post).permit(:title, :text)
  24. end
  25. end
  26.  
  27. @post.update(params[:post].permit(:title, :text))
  28.  
  29. @post.update_attributes(:title => params[:post][:title], :text => params[:post][:text])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement