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 -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 6 Mar 2008, at 09:51, Daniel Van den oord wrote:> > 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 welcomeI''m not 100% sure i''ve understood your question, but is @person.attributes what you''re after ? Fred> > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung 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 ? > > FredThanks 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 -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---