I am working with rails 2.0.2 and ActiveResource
I have an object @person and I need to save it locally and send the same
object with Active Resource to a Restfull server…
My solution to this is to define a
@person.new(params[:person]) and a RestFullPerson hooked on
ActiveResource::Base
the problem is when I do a save of the Restfull person it need a hash
structure
so I can’t do the following:
result = RestfullPerson.new(@person)
I can’t get any to_hash methods to work. any ideas are welcome
On 6 Mar 2008, at 09:51, Daniel Van den oord wrote:
structure
so I can’t do the following:
result = RestfullPerson.new(@person)
I can’t get any to_hash methods to work. any ideas are welcome
I’m not 100% sure i’ve understood your question, but is
@person.attributes what you’re after ?
Fred
Frederick C. wrote:
On 6 Mar 2008, at 09:51, Daniel Van den oord wrote:
structure
so I can’t do the following:
result = RestfullPerson.new(@person)
I can’t get any to_hash methods to work. any ideas are welcome
I’m not 100% sure i’ve understood your question, but is
@person.attributes what you’re after ?
Fred
Thanks Fred.
This is exactly what I was looking for. You might also want to point
out that you can also do this
@person.attributes.to_options!
That will symbolize the keys, to make it look like the params[] field
that is passed to the controller
Kind Regards
Hamza