hi
I wanna crate XML file in this format.
<rsp status_code="0" status_message="Success">
<daily_counts>
<count date="20100415T00:00:00">214</count>
<count date="20100409T00:00:00">205</count>
<count date="20100410T00:00:00">14</count>
<count date="20100411T00:00:00">44</count>
<count date="20100402T00:00:00">21</count>
<count date="20100422T00:00:00">241</count>
<count date="2010041T00:00:00">14</count>
</daily_counts>
</rsp>
when I user
render :xml => @service
then it pick all the data from the table and show. But the format is not
what I want.
my table name is service-enquiries.
<service-enquiries type="array">
<service-enquiry>
<user_id type="NilClass">6</user_id>
<date type="NilClass">2009-06-22</date>
</service-enquiry>
</service-enquiries>
How I change the format?
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
user builder to build your xml template and render the template
create a file service.xml.builder in the view directory for that controller
then
xml.rsp(:status_code => "0", :status_message=>
"Success")
xml.daily_counts
@services.each do |service|
xml.count(service.code,:date=> service.date)
end
end
then render => "services"
there you have it
<rsp status_code="0" status_message="Success">
<daily_counts>
<count date="20100415T00:00:00">214</
count>
<count date="20100409T00:00:00">205</count>
<count date="20100410T00:00:00">14</count>
<count date="20100411T00:00:00">44</count>
<count date="20100402T00:00:00">21</count>
<count date="20100422T00:00:00">241</count>
<count date="2010041T00:00:00">14</count>
</daily_counts>
</rsp>
On Wed, Sep 8, 2010 at 6:18 AM, Manish Nautiyal
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:
> hi
>
> I wanna crate XML file in this format.
>
> <rsp status_code="0" status_message="Success">
> <daily_counts>
> <count date="20100415T00:00:00">214</count>
> <count date="20100409T00:00:00">205</count>
> <count date="20100410T00:00:00">14</count>
> <count date="20100411T00:00:00">44</count>
> <count date="20100402T00:00:00">21</count>
> <count date="20100422T00:00:00">241</count>
> <count date="2010041T00:00:00">14</count>
> </daily_counts>
> </rsp>
>
>
> when I user
> render :xml => @service
>
> then it pick all the data from the table and show. But the format is not
> what I want.
>
> my table name is service-enquiries.
>
> <service-enquiries type="array">
> <service-enquiry>
> <user_id type="NilClass">6</user_id>
> <date type="NilClass">2009-06-22</date>
> </service-enquiry>
> </service-enquiries>
>
> How I change the format?
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito wrote:> user builder to build your xml template and render the template > > create a file service.xml.builder in the view directory for that > controller > > then > > xml.rsp(:status_code => "0", :status_message=> "Success") > xml.daily_counts > @services.each do |service| > xml.count(service.code,:date=> service.date) > end > end > > then render => "services" > there you have it > > > > > <rsp status_code="0" status_message="Success"> > <daily_counts> > <count date="20100415T00:00:00">214</ > count> > <count date="20100409T00:00:00">205</count> > <count date="20100410T00:00:00">14</count> > <count date="20100411T00:00:00">44</count> > <count date="20100402T00:00:00">21</count> > <count date="20100422T00:00:00">241</count> > <count date="2010041T00:00:00">14</count> > </daily_counts> > </rsp>Hi radhames brito thanx for your support. Can you give the link from where I learn more. How to create XML. what you tell me above is very nice. But I wanna know how it is working. so pls if possible give me the link. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
http://api.rubyonrails.org/classes/ActionView/Base.html On Wed, Sep 8, 2010 at 2:22 PM, Manish Nautiyal <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> radhames brito wrote: > > user builder to build your xml template and render the template > > > > create a file service.xml.builder in the view directory for that > > controller > > > > then > > > > xml.rsp(:status_code => "0", :status_message=> "Success") > > xml.daily_counts > > @services.each do |service| > > xml.count(service.code,:date=> service.date) > > end > > end > > > > then render => "services" > > there you have it > > > > > > > > > > <rsp status_code="0" status_message="Success"> > > <daily_counts> > > <count date="20100415T00:00:00">214</ > > count> > > <count date="20100409T00:00:00">205</count> > > <count date="20100410T00:00:00">14</count> > > <count date="20100411T00:00:00">44</count> > > <count date="20100402T00:00:00">21</count> > > <count date="20100422T00:00:00">241</count> > > <count date="2010041T00:00:00">14</count> > > </daily_counts> > > </rsp> > > > > Hi radhames brito > > thanx for your support. > Can you give the link from where I learn more. How to create XML. > > what you tell me above is very nice. But I wanna know how it is working. > > so pls if possible give me the link. > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito wrote:> http://api.rubyonrails.org/classes/ActionView/Base.htmlthank u radhames brito. If I get any problem in this. I''ll again disturb u. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
oh please do. On Thu, Sep 9, 2010 at 2:04 AM, Manish Nautiyal <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> radhames brito wrote: > > http://api.rubyonrails.org/classes/ActionView/Base.html > > > thank u radhames brito. If I get any problem in this. I''ll again disturb > u. > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.