1

I want to run sql commands directly in my rails application. Is there any gem to do this?

For example:

I want to delete a user , who is having id 2 using below sql command

 delete from users where id=2

3 Answers 3

4
ActiveRecord::Base.connection.execute("delete from users where id=2")
Sign up to request clarification or add additional context in comments.

Comments

1

Yes. We can do that by using query_exec

Comments

0

If you want to run SQL from your browser try https://github.com/igorkasyanchuk/rails_db

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.