# ActiveRecord: Reading MySQL views

**URL:** <https://www.ruby-forum.com/t/activerecord-reading-mysql-views/83508>\
**Category:** Rails\
**Created:** [January 26, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/activerecord-reading-mysql-views/83508 "2007-01-26T19:24:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [January 26, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/activerecord-reading-mysql-views/83508/1 "2007-01-26T19:24:27Z")

</div>

My production environment is actually Oracle, in which case if I say:

set\_table\_name “v\_table”

It will treat it as a readonly table.

However, doing the same under MySQL throws an  
ActiveRecord::StatementInvalid error, saying that the table db.view  
doesn’t exist. Is there a way to get around this? I am using MySQL to  
test some new code I am working on, and wouldn’t mind making the code  
compatible across products.

Brian J.

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [January 26, 2007, 7:26pm UTC](https://www.ruby-forum.com/t/activerecord-reading-mysql-views/83508/2 "2007-01-26T19:26:28Z")

</div>

Wow that’s embarrassing, seconds after posting this it boiled down to a  
spelling mistake.

Everything works now. Sorry for the list spam.

Carry on.

Brian J.

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [January 26, 2007, 7:40pm UTC](https://www.ruby-forum.com/t/activerecord-reading-mysql-views/83508/3 "2007-01-26T19:40:32Z")

</div>

In case you need it, I’ve implemented a plugin for Rails which  
supports views in migrations and schema dumps. You can find out more  
at: [http://activewarehouse.rubyforge.org/rails\_sql\_views/](http://activewarehouse.rubyforge.org/rails_sql_views/)

It currently supports MySQL and PostgreSQL in the latest release and  
SQL Server in the trunk.

V/r  
Anthony

On 1/26/07, Brian J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Cell: 808 782-5046  
Current Location: Melbourne, FL
