comparison app/controllers/pastes_controller.rb @ 329:430dadffd91e

Fix coding style.
author edogawaconan <me@myconan.net>
date Mon, 14 Apr 2014 17:13:22 +0900
parents fec39456dcbe
children cd1c3a28b89a
comparison
equal deleted inserted replaced
328:2dda4100cb82 329:430dadffd91e
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.safe_find(params[:id]) 7 @paste = Paste.safe_find(params[:id])
8 head :not_found and return unless @paste 8 return head :not_found unless @paste
9 9
10 respond_to do |format| 10 respond_to do |format|
11 format.html { cache } 11 format.html { cache }
12 format.txt { cache } 12 format.txt { cache }
13 end 13 end
26 26
27 # POST / 27 # POST /
28 # POST /pastes.json 28 # POST /pastes.json
29 # POST /pastes.txt 29 # POST /pastes.txt
30 def create 30 def create
31 @paste = Paste.new(paste_params.merge(ip: request.remote_ip)) 31 @paste = Paste.new paste_params.merge(:ip => request.remote_ip)
32 32
33 begin 33 begin
34 respond_to do |format| 34 respond_to do |format|
35 if @paste.save 35 if @paste.save
36 @fresh = true 36 @fresh = true
37 format.html { redirect_to @paste, :notice => 'Paste was successfully created.' } 37 format.html { redirect_to @paste, :notice => "Paste was successfully created." }
38 format.json { render :json => @paste, :status => :created, :location => @paste } 38 format.json { render :json => @paste, :status => :created, :location => @paste }
39 else 39 else
40 flash.now[:alert] = @paste.errors.full_messages.to_sentence 40 flash.now[:alert] = @paste.errors.full_messages.to_sentence
41 format.html { render :action => "new" } 41 format.html { render :action => "new" }
42 format.json { render :json => @paste.errors, :status => :unprocessable_entity } 42 format.json { render :json => @paste.errors, :status => :unprocessable_entity }
66 66
67 private 67 private
68 68
69 def lowercase_path 69 def lowercase_path
70 correct_path = request.fullpath.downcase 70 correct_path = request.fullpath.downcase
71 redirect_to correct_path, :status => :moved_permanently unless 71 unless correct_path == request.fullpath
72 correct_path == request.fullpath 72 redirect_to correct_path, :status => :moved_permanently
73 end
73 end 74 end
74 75
75 def cache_key(format = request.format.symbol) 76 def cache_key(format = request.format.symbol)
76 ext = case format 77 ext = case format
77 when :txt 78 when :txt