Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DowncaseEmail < ActiveRecord::Migration
- def up
- User.all.each do |user|
- user.update_attributes :email => user.email.downcase
- end
- end
- end
- class DowncaseEmail < ActiveRecord::Migration
- def up
- if %w[MySQL PostgreSQL].include? ActiveRecord::Base.connection.adapter_name
- execute "UPDATE users SET email = LOWER(email)"
- else
- User.all.each do |user|
- user.update_attributes email: user.email.downcase
- end
- end
- end
- end
- execute("UPDATE users SET email = LOWER(email)")
- User.update_all('email = lower(email)')
Add Comment
Please, Sign In to add comment