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,9 +29,8 @@ class Projects::SnippetsController < Projects::ApplicationController | ||
29 | def create | 29 | def create |
30 | @snippet = @project.snippets.build(params[:project_snippet]) | 30 | @snippet = @project.snippets.build(params[:project_snippet]) |
31 | @snippet.author = current_user | 31 | @snippet.author = current_user |
32 | - @snippet.save | ||
33 | 32 | ||
34 | - if @snippet.valid? | 33 | + if @snippet.save |
35 | redirect_to project_snippet_path(@project, @snippet) | 34 | redirect_to project_snippet_path(@project, @snippet) |
36 | else | 35 | else |
37 | respond_with(@snippet) | 36 | respond_with(@snippet) |
@@ -42,9 +41,7 @@ class Projects::SnippetsController < Projects::ApplicationController | @@ -42,9 +41,7 @@ class Projects::SnippetsController < Projects::ApplicationController | ||
42 | end | 41 | end |
43 | 42 | ||
44 | def update | 43 | def update |
45 | - @snippet.update_attributes(params[:project_snippet]) | ||
46 | - | ||
47 | - if @snippet.valid? | 44 | + if @snippet.update_attributes(params[:project_snippet]) |
48 | redirect_to project_snippet_path(@project, @snippet) | 45 | redirect_to project_snippet_path(@project, @snippet) |
49 | else | 46 | else |
50 | respond_with(@snippet) | 47 | respond_with(@snippet) |
app/controllers/snippets_controller.rb
@@ -31,15 +31,14 @@ class SnippetsController < ApplicationController | @@ -31,15 +31,14 @@ class SnippetsController < ApplicationController | ||
31 | end | 31 | end |
32 | 32 | ||
33 | def new | 33 | def new |
34 | - @snippet = PersonalSnippet.new | 34 | + @snippet = PersonalSnippet.build |
35 | end | 35 | end |
36 | 36 | ||
37 | def create | 37 | def create |
38 | - @snippet = PersonalSnippet.new(params[:personal_snippet]) | 38 | + @snippet = PersonalSnippet.build(params[:personal_snippet]) |
39 | @snippet.author = current_user | 39 | @snippet.author = current_user |
40 | - @snippet.save | ||
41 | 40 | ||
42 | - if @snippet.valid? | 41 | + if @snippet.save |
43 | redirect_to snippet_path(@snippet) | 42 | redirect_to snippet_path(@snippet) |
44 | else | 43 | else |
45 | respond_with @snippet | 44 | respond_with @snippet |
@@ -50,9 +49,7 @@ class SnippetsController < ApplicationController | @@ -50,9 +49,7 @@ class SnippetsController < ApplicationController | ||
50 | end | 49 | end |
51 | 50 | ||
52 | def update | 51 | def update |
53 | - @snippet.update_attributes(params[:personal_snippet]) | ||
54 | - | ||
55 | - if @snippet.valid? | 52 | + if @snippet.update_attributes(params[:personal_snippet]) |
56 | redirect_to snippet_path(@snippet) | 53 | redirect_to snippet_path(@snippet) |
57 | else | 54 | else |
58 | respond_with @snippet | 55 | respond_with @snippet |
config/routes.rb
@@ -46,7 +46,7 @@ Gitlab::Application.routes.draw do | @@ -46,7 +46,7 @@ Gitlab::Application.routes.draw do | ||
46 | get "raw" | 46 | get "raw" |
47 | end | 47 | end |
48 | end | 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 | # Public namespace | 52 | # Public namespace |