Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop update could be update_all #184

Open
lelelelemon opened this issue Aug 20, 2017 · 2 comments
Open

loop update could be update_all #184

lelelelemon opened this issue Aug 20, 2017 · 2 comments

Comments

@lelelelemon
Copy link
Collaborator

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
Copy link
Owner

👍

@hyperloop-rails
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants