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 <[EMAIL PROTECTED] 
> > 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 <[EMAIL PROTECTED]
> > > wrote:
> >
> >
> >
> > On Nov 3, 9:51 pm, "casey.ellett" <[EMAIL PROTECTED]> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to