Selecting records according to an item 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
You want to use classify and constantize:

require 'set'
AUTHORIZED = Set[Product, Status, Industry]
def get_record(id, item)
  model = item.classify.constantize
  raise "Go away, hacker" unless AUTHORIZED.include? model
  model.find(id).name
end


Be careful about security, as without the unless this will access any class in your system. This is just an example.