Fix 500 error when try to create project snippet without content

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2015-08-26 23:59:52 +02:00
parent 5ea5e8f5d6
commit daa90e1182
No known key found for this signature in database
GPG Key ID: 161B5D6A44D3D88A
1 changed files with 8 additions and 3 deletions

View File

@ -30,9 +30,14 @@ class Projects::SnippetsController < Projects::ApplicationController
def create
@snippet = CreateSnippetService.new(@project, current_user,
snippet_params).execute
respond_with(@snippet,
location: namespace_project_snippet_path(@project.namespace,
@project, @snippet))
if @snippet.valid?
respond_with(@snippet,
location: namespace_project_snippet_path(@project.namespace,
@project, @snippet))
else
render :new
end
end
def edit