drhenner / ror_ecommerce

Ruby on Rails Ecommerce platform, perfect for your small business solution.
www.ror-e.com
MIT License
1.21k stars 409 forks source link

loop update could be update_all #184

Open lelelelemon opened 7 years ago

lelelelemon commented 7 years ago

app/controllers/application_controller.rb

129    session_cart.cart_items.each do |item|
130      item.update_attribute(:user_id, user.id ) if item.user_id != user.id
131   end

replaced by update_all

session_cart.cart_items.where.not(user_id: user.id).update_all(user_id: user.id)
drhenner commented 7 years ago

👍

hyperloop-rails commented 6 years ago

Hello. You may remember us as we have previously opened this as a potential performance issue. Here is a shameless plug for the tool that we have developed called PowerStation for this purpose. It is a static Rails code analyzer that can identify and automatically suggest fixes for many performance issues. It has been integrated into the RubyMine IDE and can also run as a command line tool as well. Our project page includes a demo video and further documentation. We hope you will give it a try! Feedback and pull requests are welcomed.