Rob Nichols wrote:
David Fitzgibbon wrote:
Try:
eval(model_name).find(:all) Splendid. This worked a treat:
if eval(history.model).find(:first, :conditions => ["id = ?", history.item_id.to_i])
Thank you David and Chris for your prompt and useful responses.
You can also do model_name.constantize.find...... if however 'model_name' isn't the actual name of the class - meaning 'MyTable' and not eg. 'my_tables' - you need to call classify first, eg. model_name.classify.constantize.find...
eval is also pretty cool though :]
Hope this helps! Cheery-o Gustav Paul gustav@rails.co.za