[refs #733] add check for correct answer

This commit is contained in:
Alexander Machehin 2012-11-28 20:43:38 +06:00
parent e7e80164cb
commit 663db6e7ff
1 changed files with 3 additions and 1 deletions

View File

@ -52,7 +52,9 @@ class Api::V1::BuildListsController < Api::V1::BaseController
private private
def render_json(action_name) def render_json(action_name)
if @build_list.send(action_name) if !@build_list.send "can_#{action_name}?"
render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => "Incorrect action for current status"}
elsif @build_list.send(action_name)
render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")} render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")}
else else
render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")} render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")}