Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PostsController < ApplicationController
- def update
- @post = Post.find(params[:id])
- if @post.update(params[:post].permit(:title, :text))
- redirect_to @post
- else
- render 'edit'
- end
- end
- def destroy
- @post = Post.find(params[:id])
- @post.destroy
- redirect_to display_posts_path
- end
- private
- def post_params
- params.require(:post).permit(:title, :text)
- end
- end
- @post.update(params[:post].permit(:title, :text))
- @post.update_attributes(:title => params[:post][:title], :text => params[:post][:text])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement