Commit 0359f1d9ec286fbbf58027e2cdb2a307806f54da
1 parent
3e695acf
Exists in
master
and in
4 other branches
Codestyle improved
Showing
3 changed files
with
7 additions
and
13 deletions
Show diff stats
app/controllers/projects/snippets_controller.rb
| ... | ... | @@ -29,9 +29,8 @@ class Projects::SnippetsController < Projects::ApplicationController |
| 29 | 29 | def create |
| 30 | 30 | @snippet = @project.snippets.build(params[:project_snippet]) |
| 31 | 31 | @snippet.author = current_user |
| 32 | - @snippet.save | |
| 33 | 32 | |
| 34 | - if @snippet.valid? | |
| 33 | + if @snippet.save | |
| 35 | 34 | redirect_to project_snippet_path(@project, @snippet) |
| 36 | 35 | else |
| 37 | 36 | respond_with(@snippet) |
| ... | ... | @@ -42,9 +41,7 @@ class Projects::SnippetsController < Projects::ApplicationController |
| 42 | 41 | end |
| 43 | 42 | |
| 44 | 43 | def update |
| 45 | - @snippet.update_attributes(params[:project_snippet]) | |
| 46 | - | |
| 47 | - if @snippet.valid? | |
| 44 | + if @snippet.update_attributes(params[:project_snippet]) | |
| 48 | 45 | redirect_to project_snippet_path(@project, @snippet) |
| 49 | 46 | else |
| 50 | 47 | respond_with(@snippet) | ... | ... |
app/controllers/snippets_controller.rb
| ... | ... | @@ -31,15 +31,14 @@ class SnippetsController < ApplicationController |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 33 | def new |
| 34 | - @snippet = PersonalSnippet.new | |
| 34 | + @snippet = PersonalSnippet.build | |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | def create |
| 38 | - @snippet = PersonalSnippet.new(params[:personal_snippet]) | |
| 38 | + @snippet = PersonalSnippet.build(params[:personal_snippet]) | |
| 39 | 39 | @snippet.author = current_user |
| 40 | - @snippet.save | |
| 41 | 40 | |
| 42 | - if @snippet.valid? | |
| 41 | + if @snippet.save | |
| 43 | 42 | redirect_to snippet_path(@snippet) |
| 44 | 43 | else |
| 45 | 44 | respond_with @snippet |
| ... | ... | @@ -50,9 +49,7 @@ class SnippetsController < ApplicationController |
| 50 | 49 | end |
| 51 | 50 | |
| 52 | 51 | def update |
| 53 | - @snippet.update_attributes(params[:personal_snippet]) | |
| 54 | - | |
| 55 | - if @snippet.valid? | |
| 52 | + if @snippet.update_attributes(params[:personal_snippet]) | |
| 56 | 53 | redirect_to snippet_path(@snippet) |
| 57 | 54 | else |
| 58 | 55 | respond_with @snippet | ... | ... |
config/routes.rb
| ... | ... | @@ -46,7 +46,7 @@ Gitlab::Application.routes.draw do |
| 46 | 46 | get "raw" |
| 47 | 47 | end |
| 48 | 48 | end |
| 49 | - match "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ } | |
| 49 | + get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ } | |
| 50 | 50 | |
| 51 | 51 | # |
| 52 | 52 | # Public namespace | ... | ... |