Hi all, I have this method which, ideally, I would like to work in such a way as I pass in three string values, the first is the name of the object I am trying to instantiate, the second a string value corresponding to an attribute for that object and finally the value that the attribute gets updated with.
The second half of this I have working, but instantiating an object from a string value is not working. I have done several searches and have come up with a solution that runs the correct query but doesn't seem to create an actual object. Here is what I have: params => {:model => "user", :attr => "name", "user" => { "name" => "John"}} def save_update @obj = Object.const_get(:"#{params[:model]}").find(:first, :conditions => ["upper(#{params[:attr]}) = ?", params[:"#{params[:model]}"][:"#{params[:attr]}"]]) if !@obj.blank? end end When I get to the line checking to make sure the object is not blank results in failure. I guess my question is is this even possible and does anybody have any suggestion on how to make this work? Thanks, -S -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.