I use Ruby 1.8.7. I have a method which selects records according to the item that I pass to the method.
In my opinion, the code is not DRY. Could somebody offer suggestions on refactoring it to make it shorter?
def get_record (id,item)
case item
when "category"
@temp = Category.find(id)
when "status"
@temp = Status.find(id)
when "industry"
@temp = Industry.find(id)
end
return @temp.name if @temp
end