Running loops or multi-line code on Heroku Console

it's not an error - it's a feature of how Heroku let's you interact with your application via the heroku console command - whilst appearing like a full console it simply isn't. Each line is transmitted over http and evaluated when you press enter so you can't actually use multiline commands, this will work though;

User.all.each {|user| user.update_attributes(:active => true) }

if it can't be written on one line you'll need to use a rake task or such like

EDITED: To contain correct syntax


The proper syntax for this would be (at least for Ruby 1.9.2 on Heroku):

User.all.each {|user| user.update_attributes(:active => true)}

Using John's method didn't work for me (and I ran into this issue a 2nd time so it was time to write an answer that worked for others).

By the way, if you want multiple lines of code, you have to pass it all in as one line like this:

User.all.each {|user| user.some_attribute = true; user.some_other_attribute = false; user.save }