When I use pp on an object in rails, it prints out a nice string representation of the object. I am trying to pass objects from one server to another and I am wondering if I can just pass this string and create an object on the other server. Any libraries/functions out there that can do this? Or any other way to do this (not necessarily using pp). Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
> When I use pp on an object in rails, it prints out a nice string > representation of the object. I am trying to pass objects from one > server to another and I am wondering if I can just pass this string > and > create an object on the other server. Any libraries/functions out > there > that can do this? Or any other way to do this (not necessarily using > pp).If you really want to go that route you might look at converting it to YAML... but I''d also suggest looking at JSON, XML, XML-RPC, REST, active resource, etc... -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:> > If you really want to go that route you might look at converting it to > YAML... but I''d also suggest looking at JSON, XML, XML-RPC, REST, > active resource, etc... > > -philipThanks for the quick reply! Right now I am just creating a pipe-delimited string of the object attributes. Then the other server takes that string, splits it on | and populates a new object. Really I am just wondering if there is a one liner from a library where I can do this. JSON, etc.. would be overkill, since I can easily do it with a pipe-delimited string. I might just code a utility to do this with the pp string unless someone has some code that already does this. let me know.. thanks -- 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 -~----------~----~----~----~------~----~------~--~---
>> >> If you really want to go that route you might look at converting it >> to >> YAML... but I''d also suggest looking at JSON, XML, XML-RPC, REST, >> active resource, etc... >> >> -philip > > Thanks for the quick reply! > > Right now I am just creating a pipe-delimited string of the object > attributes. Then the other server takes that string, splits it on | > and > populates a new object. Really I am just wondering if there is a one > liner from a library where I can do this. JSON, etc.. would be > overkill, since I can easily do it with a pipe-delimited string. I > might just code a utility to do this with the pp string unless someone > has some code that already does this. let me know.. thankhttp://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/classes/YAML.html#M010508 http://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/classes/YAML.html#M010509 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom wrote:>> Right now I am just creating a pipe-delimited string of the object >> attributes. Then the other server takes that string, splits it on | >> and >> populates a new object. Really I am just wondering if there is a one >> liner from a library where I can do this. JSON, etc.. would be >> overkill, since I can easily do it with a pipe-delimited string. I >> might just code a utility to do this with the pp string unless someone >> has some code that already does this. let me know.. thank > > http://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/classes/YAML.html#M010508 > http://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/classes/YAML.html#M010509Ah.. you da man. Thanks, I guess I overlooked that ;-) That does exactly what I need it to. -- 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 -~----------~----~----~----~------~----~------~--~---
Here is the full implementation in case anyone is interested. Server 2 needs to get a widget object from server 1 Server 1 code -------------- WidgetController def show_widget_yaml @widget = Widget.find(params[:id]) render :layout => false end show_widget_yaml.rhtml <%=YAML.dump(@product)%> Server 2 code ------------ def show client = HTTPClient.new response = client.get(''http://www.server1/widgets/show_widget_yaml''+params[:id]) yaml_string = response.body.content @product = Product.new @product = YAML.load(yaml_string) end -- 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 -~----------~----~----~----~------~----~------~--~---
Yanni Mac wrote:> Here is the full implementation in case anyone is interested. > > Server 2 needs to get a widget object from server 1 > > > Server 1 code > -------------- > WidgetController > def show_widget_yaml > @widget = Widget.find(params[:id]) > render :layout => false > end > > show_widget_yaml.rhtml > <%=YAML.dump(@product)%> > > > > Server 2 code > ------------ > def show > client = HTTPClient.new > response = > client.get(''http://www.server1/widgets/show_widget_yaml''+params[:id]) > yaml_string = response.body.content > @product = Product.new > @product = YAML.load(yaml_string) > endCorrection.. I forgot to replace some variable names from my own code Server 1 code ----------------- WidgetController def show_widget_yaml @widget = Widget.find(params[:id]) render :layout => false end show_widget_yaml.rhtml <%=YAML.dump(@widget)%> Server 2 code ------------ def show client = HTTPClient.new response client.get(''http://www.server1/widgets/show_widget_yaml''+params[:id]) yaml_string = response.body.content @widget = Widget.new @widget = YAML.load(yaml_string) end -- 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 -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- How can i read a properties file in RoR
- How to get soap4r to not bother verifying SSL certificate (verify_mode none)?
- J2EE equivalent
- Running specs for a plugin - undefined method ''define'' for object
- Trouble with ENC and static.pp : enabling ENC fails to find node even with default node in site.pp