Forgive my ignorance, but I have searched for a while and cannot find anything that would help me move in the right direction. I need to generate xml that will then be recored in the database so that I can pull out at a later date. Every bit of info I could find shows how to create the xml and display it through a .rxml view. I also have to be able to assemble the data points for the xml from several different tables (I basically need to pull all of the has_one and has_many relationships for a particular table and construct the xml with them). A push in the right direction would be awesome. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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
2008-Nov-03 22:44 UTC
Re: Need to generate xml to be stored in a database
On Nov 3, 9:51 pm, "casey.ellett" <casey.ell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Forgive my ignorance, but I have searched for a while and cannot find > anything that would help me move in the right direction. > I need to generate xml that will then be recored in the database so > that I can pull out at a later date. > Every bit of info I could find shows how to create the xml and display > it through a .rxml view.Check out the builder library - it''s what rxml templates use. Fred> > I also have to be able to assemble the data points for the xml from > several different tables (I basically need to pull all of the has_one > and has_many relationships for a particular table and construct the > xml with them). > > A push in the right direction would be awesome. > > Thanks.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have successfully been able to create the xml I needed as a view, but how do I go from that to storing it as a record in the database? On Mon, Nov 3, 2008 at 5:44 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Nov 3, 9:51 pm, "casey.ellett" <casey.ell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Forgive my ignorance, but I have searched for a while and cannot find > > anything that would help me move in the right direction. > > I need to generate xml that will then be recored in the database so > > that I can pull out at a later date. > > Every bit of info I could find shows how to create the xml and display > > it through a .rxml view. > Check out the builder library - it''s what rxml templates use. > > Fred > > > > I also have to be able to assemble the data points for the xml from > > several different tables (I basically need to pull all of the has_one > > and has_many relationships for a particular table and construct the > > xml with them). > > > > A push in the right direction would be awesome. > > > > Thanks. > > >--~--~---------~--~----~------------~-------~--~----~ 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
2008-Nov-04 14:19 UTC
Re: Need to generate xml to be stored in a database
On 4 Nov 2008, at 13:54, Casey Ellett wrote:> I have successfully been able to create the xml I needed as a view, > but how do I go from that to storing it as a record in the database? >Well, having generated the xml, what''s stopping you assigning it to some attribute of some ActiveRecord object ? Fred> > On Mon, Nov 3, 2008 at 5:44 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > wrote: > > > > On Nov 3, 9:51 pm, "casey.ellett" <casey.ell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Forgive my ignorance, but I have searched for a while and cannot > find > > anything that would help me move in the right direction. > > I need to generate xml that will then be recored in the database so > > that I can pull out at a later date. > > Every bit of info I could find shows how to create the xml and > display > > it through a .rxml view. > Check out the builder library - it''s what rxml templates use. > > Fred > > > > I also have to be able to assemble the data points for the xml from > > several different tables (I basically need to pull all of the > has_one > > and has_many relationships for a particular table and construct the > > xml with them). > > > > A push in the right direction would be awesome. > > > > Thanks. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My complete lack of knowledge of how I would do that. I am very new to this. Can I handle that in the method I''ve put in the controller to collect the data and render the xml? Currently I am just pulling in a specific category object in the controller and specifying a view: def cat_xml @category = Category.find(params[:id]) respond_to do |format| format.html # index.html.erb format.xml { render :action => "cat.xml.builder", :layout => false } end end And I have the xml Builder template in: cat_xml.xml.builder Where would I assign this view to an ActiveRecord object? Or am I going down the wrong path here? I don''t actually need to view the xml at any point - I''m actually going to pull it out of the database at a later point and send it up to a web service. Or I guess I could send it as it''s generated, I just want to save it to pull it later if need be. Thanks for taking an interest in helping me out, by the way. On Tue, Nov 4, 2008 at 9:19 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 4 Nov 2008, at 13:54, Casey Ellett wrote: > > > I have successfully been able to create the xml I needed as a view, > > but how do I go from that to storing it as a record in the database? > > > Well, having generated the xml, what''s stopping you assigning it to > some attribute of some ActiveRecord object ? > > Fred > > > > On Mon, Nov 3, 2008 at 5:44 PM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > wrote: > > > > > > > > On Nov 3, 9:51 pm, "casey.ellett" <casey.ell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Forgive my ignorance, but I have searched for a while and cannot > > find > > > anything that would help me move in the right direction. > > > I need to generate xml that will then be recored in the database so > > > that I can pull out at a later date. > > > Every bit of info I could find shows how to create the xml and > > display > > > it through a .rxml view. > > Check out the builder library - it''s what rxml templates use. > > > > Fred > > > > > > I also have to be able to assemble the data points for the xml from > > > several different tables (I basically need to pull all of the > > has_one > > > and has_many relationships for a particular table and construct the > > > xml with them). > > > > > > A push in the right direction would be awesome. > > > > > > Thanks. > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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
2008-Nov-04 15:09 UTC
Re: Need to generate xml to be stored in a database
On 4 Nov 2008, at 15:04, Casey Ellett wrote:> My complete lack of knowledge of how I would do that. I am very new > to this. > Can I handle that in the method I''ve put in the controller to > collect the data and render the xml? > > Currently I am just pulling in a specific category object in the > controller and specifying a view: > > def cat_xml > @category = Category.find(params[:id]) > > respond_to do |format| > format.html # index.html.erb > format.xml { render :action => "cat.xml.builder", :layout => > false } > end > > end > > And I have the xml Builder template in: > > cat_xml.xml.builder > > Where would I assign this view to an ActiveRecord object? > > Or am I going down the wrong path here? I don''t actually need to > view the xml at any point - I''m actually going to pull it out of the > database at a later point and send it up to a web service. Or I > guess I could send it as it''s generated, I just want to save it to > pull it later if need be. >If you don''t have a view, you don''t need a template. you can do something like xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! ... #buildery stuff here SomeObject.create :xml_text => xml.target! Fred> Thanks for taking an interest in helping me out, by the way. > > On Tue, Nov 4, 2008 at 9:19 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > wrote: > > > On 4 Nov 2008, at 13:54, Casey Ellett wrote: > > > I have successfully been able to create the xml I needed as a view, > > but how do I go from that to storing it as a record in the database? > > > Well, having generated the xml, what''s stopping you assigning it to > some attribute of some ActiveRecord object ? > > Fred > > > > On Mon, Nov 3, 2008 at 5:44 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > > wrote: > > > > > > > > On Nov 3, 9:51 pm, "casey.ellett" <casey.ell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Forgive my ignorance, but I have searched for a while and cannot > > find > > > anything that would help me move in the right direction. > > > I need to generate xml that will then be recored in the database > so > > > that I can pull out at a later date. > > > Every bit of info I could find shows how to create the xml and > > display > > > it through a .rxml view. > > Check out the builder library - it''s what rxml templates use. > > > > Fred > > > > > > I also have to be able to assemble the data points for the xml > from > > > several different tables (I basically need to pull all of the > > has_one > > > and has_many relationships for a particular table and construct > the > > > xml with them). > > > > > > A push in the right direction would be awesome. > > > > > > Thanks. > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Tue, Nov 4, 2008 at 11:09 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > Or am I going down the wrong path here? I don''t actually need to > > view the xml at any point - I''m actually going to pull it out of the > > database at a later point and send it up to a web service. Or I > > guess I could send it as it''s generated, I just want to save it to > > pull it later if need be. >We do this very same thing. It may or may not be the best solution, but we store the xml in a temp file on the server, and then have the path listed in our MySQL database as text. We just read the whole thing and pass to the web service when we''re ready to move on. Our process goes like this: 1) Customer creates a cart and checks out. 2) Call web services to generate the completed order xml. 3) Save order xml into temp text file and put the path into the db. 4) Display confirmation page with totals/taxes (generated from web service). 5) If confirmed, read order xml and call save method in web service. It''s simple and doesn''t require a whole bunch of coding. It also gives you a nice history to look at if there are any problems with the xml. We remove the xml temp file once the order has been completed so it doesn''t eat all of our server space. Hope this helps! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ll give this a go tonight. Thanks. On Tue, Nov 4, 2008 at 12:02 PM, Sheryl Barrow <plotchick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Tue, Nov 4, 2008 at 11:09 AM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> > Or am I going down the wrong path here? I don''t actually need to >> > view the xml at any point - I''m actually going to pull it out of the >> > database at a later point and send it up to a web service. Or I >> > guess I could send it as it''s generated, I just want to save it to >> > pull it later if need be. >> > > We do this very same thing. It may or may not be the best solution, but we > store the xml in a temp file on the server, and then have the path listed in > our MySQL database as text. We just read the whole thing and pass to the web > service when we''re ready to move on. > > Our process goes like this: > > 1) Customer creates a cart and checks out. > 2) Call web services to generate the completed order xml. > 3) Save order xml into temp text file and put the path into the db. > 4) Display confirmation page with totals/taxes (generated from web > service). > 5) If confirmed, read order xml and call save method in web service. > > It''s simple and doesn''t require a whole bunch of coding. It also gives you > a nice history to look at if there are any problems with the xml. > > We remove the xml temp file once the order has been completed so it doesn''t > eat all of our server space. > > Hope this helps! > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I got this sorted out. I ended up creating the new ActiveRecord object and passing the xml from builder into that. Thank you for your help. On Tue, Nov 4, 2008 at 2:31 PM, Casey Ellett <casey.ellett-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ll give this a go tonight. Thanks. > > > On Tue, Nov 4, 2008 at 12:02 PM, Sheryl Barrow <plotchick-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> >> On Tue, Nov 4, 2008 at 11:09 AM, Frederick Cheung < >> frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> >>> >>> > Or am I going down the wrong path here? I don''t actually need to >>> > view the xml at any point - I''m actually going to pull it out of the >>> > database at a later point and send it up to a web service. Or I >>> > guess I could send it as it''s generated, I just want to save it to >>> > pull it later if need be. >>> >> >> We do this very same thing. It may or may not be the best solution, but >> we store the xml in a temp file on the server, and then have the path listed >> in our MySQL database as text. We just read the whole thing and pass to the >> web service when we''re ready to move on. >> >> Our process goes like this: >> >> 1) Customer creates a cart and checks out. >> 2) Call web services to generate the completed order xml. >> 3) Save order xml into temp text file and put the path into the db. >> 4) Display confirmation page with totals/taxes (generated from web >> service). >> 5) If confirmed, read order xml and call save method in web service. >> >> It''s simple and doesn''t require a whole bunch of coding. It also gives >> you a nice history to look at if there are any problems with the xml. >> >> We remove the xml temp file once the order has been completed so it >> doesn''t eat all of our server space. >> >> Hope this helps! >> >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---