comparison app/controllers/pastes_controller.rb @ 212:186b4674bcbe

Add controller support for is_private flag
author Edho Arief <edho@myconan.net>
date Sun, 12 May 2013 02:41:35 +0900
parents 5e1d728975a4
children 9998d8b6c524
comparison
equal deleted inserted replaced
211:5e1d728975a4 212:186b4674bcbe
2 caches_page :show 2 caches_page :show
3 3
4 # GET /1 4 # GET /1
5 # GET /1.txt 5 # GET /1.txt
6 def show 6 def show
7 @paste = Paste.find(params[:id]) 7 @paste = Paste.safe_find(params[:id])
8 8
9 expires_in 1.year, :public => true 9 expires_in 1.year, :public => true
10 respond_to do |format| 10 respond_to do |format|
11 format.html # show.html.erb 11 format.html # show.html.erb
12 format.txt # show.txt.erb 12 format.txt # show.txt.erb
60 end 60 end
61 end 61 end
62 end 62 end
63 63
64 def destroy 64 def destroy
65 @paste = Paste.find(params[:id]) 65 @paste = Paste.safe_find(params[:id])
66 if @paste.key == params[:paste][:key] 66 if @paste.key == params[:paste][:key]
67 @paste.destroy 67 @paste.destroy
68 expire_page :controller => 'pastes', :action => 'show', :id => @paste.id 68 expire_page :controller => 'pastes', :action => 'show', :id => @paste.id
69 flash[:notice] = "Paste ##{params[:id]} deleted" 69 flash[:notice] = "Paste ##{params[:id]} deleted"
70 redirect_to root_path 70 redirect_to root_path
74 end 74 end
75 end 75 end
76 76
77 private 77 private
78 def paste_params 78 def paste_params
79 params.require(:paste).permit(:paste, :key) 79 params.require(:paste).permit(:paste, :is_private, :key)
80 end 80 end
81 end 81 end