#53: some refactoring according to discussion

This commit is contained in:
Vokhmin Alexey V 2013-04-02 15:04:51 +04:00
parent e7b07cdfca
commit c9b04a6acc
1 changed files with 2 additions and 1 deletions

View File

@ -34,6 +34,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
def publish
@build_list.publisher = current_user
@build_list.save
render_json :publish
end
@ -48,7 +49,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
private
def render_json(action_name, action_method = nil)
if @build_list.save && @build_list.try("can_#{action_name}?") && @build_list.send(action_method || action_name)
if @build_list.try("can_#{action_name}?") && @build_list.send(action_method || action_name)
render_json_response @build_list, t("layout.build_lists.#{action_name}_success")
else
render_validation_error @build_list, t("layout.build_lists.#{action_name}_fail")