[Rails] Other way instead of this evil eval?

2011-05-03 Thread David Kahn
I am trying to do this, where associated_record_type is always of the name of a model, passed to the method: record = eval(#{associated_record_type}).find_by_id(associated_record_id) Is there a way to do this dynamically without using an eval? -- You received this message because you are

Re: [Rails] Other way instead of this evil eval?

2011-05-03 Thread Michael Pavling
On 3 May 2011 20:26, David Kahn d...@structuralartistry.com wrote: record =  eval(#{associated_record_type}).find_by_id(associated_record_id) Is there a way to do this dynamically without using an eval? record =  associated_record_type.classify.constantize.find_by_id(associated_record_id) --

Re: [Rails] Other way instead of this evil eval?

2011-05-03 Thread Michael Pavling
On 3 May 2011 20:30, Michael Pavling pavl...@gmail.com wrote: On 3 May 2011 20:26, David Kahn d...@structuralartistry.com wrote: record =  eval(#{associated_record_type}).find_by_id(associated_record_id) Is there a way to do this dynamically without using an eval? record = 

Re: [Rails] Other way instead of this evil eval?

2011-05-03 Thread David Kahn
On Tue, May 3, 2011 at 2:33 PM, Michael Pavling pavl...@gmail.com wrote: On 3 May 2011 20:30, Michael Pavling pavl...@gmail.com wrote: On 3 May 2011 20:26, David Kahn d...@structuralartistry.com wrote: record = eval(#{associated_record_type}).find_by_id(associated_record_id) Is there a