summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/snippets_controller.rb7
-rw-r--r--app/controllers/snippets_controller.rb11
-rw-r--r--config/routes.rb2
3 files changed, 7 insertions, 13 deletions
diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb
index 92e88de6790..1165fa1c583 100644
--- a/app/controllers/projects/snippets_controller.rb
+++ b/app/controllers/projects/snippets_controller.rb
@@ -29,9 +29,8 @@ class Projects::SnippetsController < Projects::ApplicationController
def create
@snippet = @project.snippets.build(params[:project_snippet])
@snippet.author = current_user
- @snippet.save
- if @snippet.valid?
+ if @snippet.save
redirect_to project_snippet_path(@project, @snippet)
else
respond_with(@snippet)
@@ -42,9 +41,7 @@ class Projects::SnippetsController < Projects::ApplicationController
end
def update
- @snippet.update_attributes(params[:project_snippet])
-
- if @snippet.valid?
+ if @snippet.update_attributes(params[:project_snippet])
redirect_to project_snippet_path(@project, @snippet)
else
respond_with(@snippet)
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 2062ceafa9c..7c96b82379c 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -31,15 +31,14 @@ class SnippetsController < ApplicationController
end
def new
- @snippet = PersonalSnippet.new
+ @snippet = PersonalSnippet.build
end
def create
- @snippet = PersonalSnippet.new(params[:personal_snippet])
+ @snippet = PersonalSnippet.build(params[:personal_snippet])
@snippet.author = current_user
- @snippet.save
- if @snippet.valid?
+ if @snippet.save
redirect_to snippet_path(@snippet)
else
respond_with @snippet
@@ -50,9 +49,7 @@ class SnippetsController < ApplicationController
end
def update
- @snippet.update_attributes(params[:personal_snippet])
-
- if @snippet.valid?
+ if @snippet.update_attributes(params[:personal_snippet])
redirect_to snippet_path(@snippet)
else
respond_with @snippet
diff --git a/config/routes.rb b/config/routes.rb
index 4501d79e650..97436025965 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -46,7 +46,7 @@ Gitlab::Application.routes.draw do
get "raw"
end
end
- match "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
+ get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
#
# Public namespace