# ActiveRecord.save With No SELECT Privileges (MySQL)

**URL:** <https://www.ruby-forum.com/t/activerecord-save-with-no-select-privileges-mysql/165187>\
**Category:** Rails\
**Created:** [April 9, 2009, 11:58pm UTC](https://www.ruby-forum.com/t/activerecord-save-with-no-select-privileges-mysql/165187 "2009-04-09T23:58:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [April 9, 2009, 11:58pm UTC](https://www.ruby-forum.com/t/activerecord-save-with-no-select-privileges-mysql/165187/1 "2009-04-09T23:58:45Z")

</div>

I’m writing a customer-facing application that’s responsible for  
obtaining extremely sensitive data, much to my dismay and despite my  
vehement protests. Long story short, to stay in compliance with  
various policies, and because I’m insanely paranoid, I’ll need to  
capture this user data and write it into a SECOND database as a user  
who has ONLY the “insert” privilege.

Database 1: Contains application data (inventory, e-commerce based  
stuff, etc.) - Primary Rails Application DB  
Database 2: Rails app connects as a user with only one privilege:  
insert.

I whipped up a quick test using MySQL and Rails 2.2.2 (I haven’t  
upgraded yet, but I will when this project is finished). I created a  
simple “users” table manually without an AR Migration, and then fired  
up script/console and executed “@u = User.new”. It complained that  
the SELECT privilege was denied (which is the point).

Obviously it needs SELECT to find out which fields - or methods - to  
assign to the User model (in this case). Is there any way I can  
achieve basic AR functionality (AR.save and AR.new, as well as  
AR.some\_method = value) without giving this user SELECT privileges?

---

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [April 10, 2009, 1:08am UTC](https://www.ruby-forum.com/t/activerecord-save-with-no-select-privileges-mysql/165187/2 "2009-04-10T01:08:55Z")

</div>

On Apr 9, 10:57 pm, Phoenix R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m writing a customer-facing application that’s responsible for  
> obtaining extremely sensitive data, much to my dismay and despite my  
> vehement protests. Long story short, to stay in compliance with  
> various policies, and because I’m insanely paranoid, I’ll need to  
> capture this user data and write it into a SECOND database as a user  
> who has ONLY the “insert” privilege.

Have you looked at the masochism plugin ? It allows you to split reads  
and writes to two different db servers. The intent is to deal with the  
pattern where you write to the database master and from the slave(s),  
but it might also be useful in your case.

Fred
