Mercurial > zeropaste
comparison app/controllers/pastes_controller.rb @ 499:d2ef59c9a4b4
Use rails rubocop
author | nanaya <me@nanaya.net> |
---|---|
date | Sun, 15 Dec 2024 22:33:27 +0900 |
parents | f11862e58af4 |
children |
comparison
equal
deleted
inserted
replaced
498:300bac944674 | 499:d2ef59c9a4b4 |
---|---|
4 def show | 4 def show |
5 @paste = Paste.safe_find(params[:id]) | 5 @paste = Paste.safe_find(params[:id]) |
6 return head :not_found unless @paste | 6 return head :not_found unless @paste |
7 | 7 |
8 if params[:id] != @paste.to_param | 8 if params[:id] != @paste.to_param |
9 redirect_to :action => :show, | 9 redirect_to action: :show, |
10 :id => @paste.to_param, | 10 id: @paste.to_param, |
11 :format => params[:format] | 11 format: params[:format] |
12 return | 12 return |
13 end | 13 end |
14 | 14 |
15 respond_to do |format| | 15 respond_to do |format| |
16 format.html | 16 format.html |
31 | 31 |
32 # POST / | 32 # POST / |
33 # POST /pastes.json | 33 # POST /pastes.json |
34 # POST /pastes.txt | 34 # POST /pastes.txt |
35 def create | 35 def create |
36 created, @paste, @fresh = Paste.graceful_create paste_params.merge(:ip => request.remote_ip) | 36 created, @paste, @fresh = Paste.graceful_create paste_params.merge(ip: request.remote_ip) |
37 | 37 |
38 respond_to do |format| | 38 respond_to do |format| |
39 if created | 39 if created |
40 if @fresh | 40 if @fresh |
41 format.html { redirect_to @paste, :notice => "Paste was successfully created." } | 41 format.html { redirect_to @paste, notice: "Paste was successfully created." } |
42 format.json { render :json => @paste, :status => :created, :location => @paste } | 42 format.json { render json: @paste, status: :created, location: @paste } |
43 else | 43 else |
44 format.html { redirect_to paste_path(@paste) } | 44 format.html { redirect_to paste_path(@paste) } |
45 format.json { render :json => @paste } | 45 format.json { render json: @paste } |
46 end | 46 end |
47 else | 47 else |
48 flash.now[:alert] = @paste.errors.full_messages.to_sentence | 48 flash.now[:alert] = @paste.errors.full_messages.to_sentence |
49 format.html { render :action => "new" } | 49 format.html { render action: "new" } |
50 format.json { render :json => @paste.errors, :status => :unprocessable_entity } | 50 format.json { render json: @paste.errors, status: :unprocessable_entity } |
51 end | 51 end |
52 format.txt | 52 format.txt |
53 end | 53 end |
54 end | 54 end |
55 | 55 |
56 def destroy | 56 def destroy |
57 @paste = Paste.safe_find(params[:id]) | 57 @paste = Paste.safe_find(params[:id]) |
58 if @paste.safe_destroy(params[:paste][:key]) | 58 if @paste.safe_destroy(params[:paste][:key]) |
59 redirect_to root_path, :notice => "Paste ##{params[:id]} deleted" | 59 redirect_to root_path, notice: "Paste ##{params[:id]} deleted" |
60 else | 60 else |
61 flash.now[:alert] = @paste.errors.full_messages.to_sentence | 61 flash.now[:alert] = @paste.errors.full_messages.to_sentence |
62 render :show | 62 render :show |
63 end | 63 end |
64 end | 64 end |