From: Ezra Zygmuntowicz Date: 2007-02-02T16:05:08+09:00 Subject: Re: How to Convert an Object into a Hash On Feb 1, 2007, at 10:45 PM, Jason Vogel wrote: > I have an object (happens to be an ActiveRecord Model), but this is > not a Rails question. > > params = { :contract_id => contract_payment['contract_id'], :amount => > contract_payment['amount'] } > > params = contract_payment.to_hash # This is what I want to do... > > I want to "automagically" convert the contract_payment object to a > hash. > > I would really appreciate any help. > > Thanks, > Jason > > Since you are using ActiveRecord you can already get the attributes hash: contract_payment.attributes Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)