Hi, the array below is the output from a find(:all) [#<Boekingen affnr: "vl999", pnr: "MA5OSG", agent: "monties", ticket_prijs: #<BigDecimal:b775f4c4,''0.138E3'',4(12)>, aantal_pers: 2, ticket_fees: nil, res_kosten: nil, commissie: nil, ticket_verz: nil, tax: nil, total_prijs: #<BigDecimal:b775f230,''0.36316E3'',8(12)>, bet_id: nil, vertrek_id: "AMS", bestemming_id: "MAD", airline_id: "HV", cabinclass: nil, type: nil, eligibility: nil, supplier: nil, heen_datum: 1020204000, terug_datum: 1049061600, outbound_v: nil, outbound_a: nil, outbound_vluchtnrs: nil, inbound_v: nil, inbound_a: nil, inbound_vluchtnrs: nil, reis_verz: #<BigDecimal:b775ed08,''0.0'',4(8)>, annu_verz: #<BigDecimal:b775eccc,''0.0'',4(8)>, boeking_status: nil, enquete_status: 1, holiday_status: 0, eurenq_status: 9, nieuwsbrief: 99, reference: nil, kadoboncode: nil, boeking_tijdcode: 1030624003, servicemail_status: nil, factory_master_id: 1>,] ectect Now i want to store all the values of the "ticket_fees" in a new array. like this... ticket_fee = ["2", "3", "1"] How can i do this(newbie) Thanks..remco -- Posted via 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
[code] ticket_fee = []find(:all).map{|record| ticket_fee << record.ticket_fees} [/code] Try it:) btw, find(:all) you can write: ''all'': Ticket.find(:all) #=> Ticket.all On Thu, Feb 26, 2009 at 5:17 PM, Remco Swoany < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > the array below is the output from a find(:all) > > [#<Boekingen affnr: "vl999", pnr: "MA5OSG", agent: "monties", > ticket_prijs: #<BigDecimal:b775f4c4,''0.138E3'',4(12)>, aantal_pers: 2, > ticket_fees: nil, res_kosten: nil, commissie: nil, ticket_verz: nil, > tax: nil, total_prijs: #<BigDecimal:b775f230,''0.36316E3'',8(12)>, bet_id: > nil, vertrek_id: "AMS", bestemming_id: "MAD", airline_id: "HV", > cabinclass: nil, type: nil, eligibility: nil, supplier: nil, heen_datum: > 1020204000, terug_datum: 1049061600, outbound_v: nil, outbound_a: nil, > outbound_vluchtnrs: nil, inbound_v: nil, inbound_a: nil, > inbound_vluchtnrs: nil, reis_verz: #<BigDecimal:b775ed08,''0.0'',4(8)>, > annu_verz: #<BigDecimal:b775eccc,''0.0'',4(8)>, boeking_status: nil, > enquete_status: 1, holiday_status: 0, eurenq_status: 9, nieuwsbrief: 99, > reference: nil, kadoboncode: nil, boeking_tijdcode: 1030624003, > servicemail_status: nil, factory_master_id: 1>,] ectect > > Now i want to store all the values of the "ticket_fees" in a new array. > > like this... > > ticket_fee = ["2", "3", "1"] > > How can i do this(newbie) > > Thanks..remco > -- > Posted via ruby-forum.com. > > > >-- TWRUG Blog: blog.rubyonrails.org.tw CFC on Rails: zusocfc.blogspot.com Only two surfaces of a box: blog.pixnet.net/zusocfc --~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 26, 9:20 am, CFC <zuso...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> [code] > ticket_fee = []find(:all).map{|record| ticket_fee << record.ticket_fees}You might as well just do find(:all).map{|record| record.ticket_fees} Fred> [/code] > > Try it:) > btw, find(:all) you can write: ''all'': > Ticket.find(:all) #=> Ticket.all > > On Thu, Feb 26, 2009 at 5:17 PM, Remco Swoany < > > > > rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > Hi, > > > the array below is the output from a find(:all) > > > [#<Boekingen affnr: "vl999", pnr: "MA5OSG", agent: "monties", > > ticket_prijs: #<BigDecimal:b775f4c4,''0.138E3'',4(12)>, aantal_pers: 2, > > ticket_fees: nil, res_kosten: nil, commissie: nil, ticket_verz: nil, > > tax: nil, total_prijs: #<BigDecimal:b775f230,''0.36316E3'',8(12)>, bet_id: > > nil, vertrek_id: "AMS", bestemming_id: "MAD", airline_id: "HV", > > cabinclass: nil, type: nil, eligibility: nil, supplier: nil, heen_datum: > > 1020204000, terug_datum: 1049061600, outbound_v: nil, outbound_a: nil, > > outbound_vluchtnrs: nil, inbound_v: nil, inbound_a: nil, > > inbound_vluchtnrs: nil, reis_verz: #<BigDecimal:b775ed08,''0.0'',4(8)>, > > annu_verz: #<BigDecimal:b775eccc,''0.0'',4(8)>, boeking_status: nil, > > enquete_status: 1, holiday_status: 0, eurenq_status: 9, nieuwsbrief: 99, > > reference: nil, kadoboncode: nil, boeking_tijdcode: 1030624003, > > servicemail_status: nil, factory_master_id: 1>,] ectect > > > Now i want to store all the values of the "ticket_fees" in a new array. > > > like this... > > > ticket_fee = ["2", "3", "1"] > > > How can i do this(newbie) > > > Thanks..remco > > -- > > Posted viahttp://www.ruby-forum.com. > > -- > TWRUG Blog:blog.rubyonrails.org.tw > > CFC on Rails:zusocfc.blogspot.com > > Only two surfaces of a box:blog.pixnet.net/zusocfc--~--~---------~--~----~------------~-------~--~----~ 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Billy Hsu wrote:> [code] > ticket_fee = []find(:all).map{|record| ticket_fee << record.ticket_fees} > [/code] > > Try it:) > btw, find(:all) you can write: ''all'': > Ticket.find(:all) #=> Ticket.all > > > > > On Thu, Feb 26, 2009 at 5:17 PM, Remco Swoany < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> cabinclass: nil, type: nil, eligibility: nil, supplier: nil, heen_datum: >> like this... >> > -- > TWRUG Blog: > blog.rubyonrails.org.tw > > CFC on Rails: > zusocfc.blogspot.com > > Only two surfaces of a box: > blog.pixnet.net/zusocfcHi Us this Factory_masters = Fusioncharts::FactoryMaster.find(:all) Output: [#<Fusioncharts::FactoryMaster id: 1, name: "vliegtickets">, #<Fusioncharts::FactoryMaster id: 2, name: "vliegticket">, #<Fusioncharts::FactoryMaster id: 3, name: "vliegtickets.nl">, #<Fusioncharts::FactoryMaster id: 4, name: "vliegtickets.nl">, #<Fusioncharts::FactoryMaster id: 5, name: "vlieg tickets">, #<Fusioncharts::FactoryMaster id: 6, name: "vliegticket.nl">, #<Fusioncharts::FactoryMaster id: 7, name: "goedkoop vliegen">, #<Fusioncharts::FactoryMaster id: 8, name: "vliegtickets nl ">, #<Fusioncharts::FactoryMaster id: 9, name: "vlieg ticket">, #<Fusioncharts::FactoryMaster id: 10, name: "vliegtarieven">, #<Fusioncharts::FactoryMaster id: 11, name: "vliegticket">] Then i use your suggestion, like this name = []Fusioncharts::FactoryMaster.find(:all).map{|record| name << record.name But i get no results... What am i doing wrong? remco -- Posted via 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Remco Swoany wrote:> Billy Hsu wrote: >> [code] >> ticket_fee = []find(:all).map{|record| ticket_fee << record.ticket_fees} >> [/code] >> >> Try it:) >> btw, find(:all) you can write: ''all'': >> Ticket.find(:all) #=> Ticket.all >> >> >> >> >> On Thu, Feb 26, 2009 at 5:17 PM, Remco Swoany < >> rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >>> cabinclass: nil, type: nil, eligibility: nil, supplier: nil, heen_datum: >>> like this... >>> >> -- >> TWRUG Blog: >> blog.rubyonrails.org.tw >> >> CFC on Rails: >> zusocfc.blogspot.com >> >> Only two surfaces of a box: >> blog.pixnet.net/zusocfc > > Hi > > Us this > Factory_masters = Fusioncharts::FactoryMaster.find(:all) > > Output: > [#<Fusioncharts::FactoryMaster id: 1, name: "vliegtickets">, > #<Fusioncharts::FactoryMaster id: 2, name: "vliegticket">, > #<Fusioncharts::FactoryMaster id: 3, name: "vliegtickets.nl">, > #<Fusioncharts::FactoryMaster id: 4, name: "vliegtickets.nl">, > #<Fusioncharts::FactoryMaster id: 5, name: "vlieg tickets">, > #<Fusioncharts::FactoryMaster id: 6, name: "vliegticket.nl">, > #<Fusioncharts::FactoryMaster id: 7, name: "goedkoop vliegen">, > #<Fusioncharts::FactoryMaster id: 8, name: "vliegtickets nl ">, > #<Fusioncharts::FactoryMaster id: 9, name: "vlieg ticket">, > #<Fusioncharts::FactoryMaster id: 10, name: "vliegtarieven">, > #<Fusioncharts::FactoryMaster id: 11, name: "vliegticket">] > > Then i use your suggestion, like this > > name = []Fusioncharts::FactoryMaster.find(:all).map{|record| name << > record.name > > But i get no results... > > What am i doing wrong? > > remcoi just find out..the solution...pff.. factory_masters.bookings.map{|record| record.departure_id}.inject(Hash.new(0)) {|h,x| h[x]+=1;h} output: ["AMS" => 4, "BCN"=> 9, "BKK"=>2] Thanks for the support! -- Posted via 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 groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---