How to update Active Record from rails console

How to update Active record from back-end using rails console

While working on rails console I figured out SQL way to update an active record from rails console.
So I have to update flag value of a field ’email_dangling’ to ‘0’

so Steps are as:

1. bundle exec rails c production

2. ActiveRecord::Base.connection.execute ‘update emails set email_dangling = 0 where id = 1234’

And its done!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s