Frederick Cheung wrote:

> You could use ModelClass.column_names / ModelClass.columns_hash to see
> if an appropriately named column exists.

As far as I can tell from the code, that is pretty much what 
has_attribute? does.  However, upon reflection I realized that my 
approach did not accommodate virtual attributes.  So, I ended up with 
this:

  def attr_set_by_names(attr_names=[],param_hash={})
    an = attr_names.to_ary
    return self unless param_hash.kind_of?(Hash) && an.length > 0
    an.each do |f|
      self.send("#{f}=", "#{param_hash[f]}") if 
self.method_exists?("#{f}=")
    end
    return self
  end

Which handles every setter method available to the class.

You assistance, as always, is greatly valued.
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to