The following is working but i am not sure if this is a better way to
write it. Can someone suggest better way to write following code
@total_unit = Unit.select('id').where('assigned = 0')
@total_unit_count = @total_unit.count
1.upto @total_unit_count do |i|
MemberProperty.create(
:unit_id => @total_unit[i-1].id,
:member_type => 'Regular',
:status => '1'
)
sql = ActiveRecord::Base.connection();
sql.execute "SET autocommit=0";
sql.begin_db_transaction
id, value =
sql.update "UPDATE `chsdesk3`. `units`
SET units.assigned='1' "
end unless @total_unit_count.nil?
--
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.