I am using raw sql queries in my rails application. I want to insert NULL value in one my rows, like how active record does using nil so that i will get that row when i do Table.find_by_column(nil). I tried '#{nil}' its entering as nothing db column is blank like this ' ' i want it to be NULL.
You can also try this.
sql = "INSERT into table_name (r_id, r_name) VALUES (1, null)"
records_array = ActiveRecord::Base.connection.execute(sql)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With