#672: small refactoring Api::V1::BaseController#member method

This commit is contained in:
Vokhmin Alexey V 2012-10-15 14:07:10 +04:00
parent 5d9a1e2586
commit 9087a15627
1 changed files with 4 additions and 8 deletions

View File

@ -71,14 +71,10 @@ class Api::V1::BaseController < ApplicationController
private
def member
return @member if @member
if params[:type] == 'User'
member = User
elsif params[:type] == 'Group'
member = Group
if @member.blank? && %w(User Group).include?(params[:type])
@member = params[:type].constantize.where(:id => params[:member_id]).first
end
@member = member.where(:id => params[:member_id]).first if member
@member ||= ''
end
@member
end
end