Hi
   Suppose I have a two models Ticket and Activity

Ticket has_many activities
Activity belongs_to Ticket

    Now suppose if the Activity has field name Now for a Ticket with
id=1 say there are 10 activities So to update name of all activities  I
can directly wite the sql statement

update activities set name='somename' where ticket_id=1

    So I am writing this like

ticket = Ticket.find(1)
ticket.activities.each do |a|
  a.update_attribute(:name => 'somename')
end
     But what about the performance Is both the above query and the ruby
code has same performance What is actually the generated sql for the
ruby code
    Or Am I wrong? Is there any other way of doing this same like sql
above?

Thanks in advance
Sijo
-- 
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to