Ruby on Rails Tuesday, January 31, 2012


tran =Transaction.select("transactions.id,transactions.user_id,transactions.branch_id,transactions.customer_id,transactions.membership_type_id,transactions.bill_amount,transactions.bill_date")
  treport = TransactionReport.new 
  puts "from report"
  tran.each do |u|
  bs = TransactionReport.new(
    :user_id => u.user_id,
    :branch_id => u.branch_id,
    :transaction_id => u.id,
    :customer_id => u.customer_id,
    :membership_type_id => u.membership_type_id,
    :bill_amount => u.bill_amount,
    :bill_date => u.bill_date
 )
  bs.save

Here the object creation will happen in loop so this will create new object for TransactionReport with each insertion. How to avoid this in rails3.....?

Thank you
vishnu



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/i2NkV2Mw9YUJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.

1 comment:

Unknown said...

Ruby on Rails is fast growing in popularity and is powering applications of some of the fastest growing companies like Twitter and Groupon to name a few.
Ruby on Rails | Ruby on Rails Development | Rails Development

Post a Comment