# RuntimeError: ERROR C42P01 Mrelation

**URL:** <https://www.ruby-forum.com/t/runtimeerror-error-c42p01-mrelation/87809>\
**Category:** Rails\
**Created:** [March 6, 2007, 3:49am UTC](https://www.ruby-forum.com/t/runtimeerror-error-c42p01-mrelation/87809 "2007-03-06T03:49:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [March 6, 2007, 3:49am UTC](https://www.ruby-forum.com/t/runtimeerror-error-c42p01-mrelation/87809/1 "2007-03-06T03:49:35Z")

</div>

Hi Guys,

Am trying to map a database ‘view’ to activerecord but i get the  
following error  
"RuntimeError: ERROR C42P01 Mrelation “gff3view” does not exist  
Fnamespace.c L200 RRangeVarGetRelid: SELECT \* FROM gff3view "

Am developing an application based on a legacy database using Postgresql  
database server.i have over 50 database views which ithought rails would  
support, just like tables.

This is what i have done;  
i installed the gem rails\_sql\_views which is supposed to among many  
other things.

# Implement view support for: MySQL and PostgreSQL

# Unit tests included

i then incuded this two lines in my enviroment.rb file

require\_gem ‘rails\_sql\_views’  
require ‘rails\_sql\_views’

then in my model i wrote this:

class Myview \< ActiveRecord::Base

def self.find\_feature  
find(:all)  
end  
end

in my controller i have:

class DisplayController \< ApplicationController

def index  
@myviews = Myview.find\_feature  
end  
end

and in my index.rhtml i have

h1\>Features Display

\<%for myview in @myviews -%\>

```
    <div class= "entry">

```

### Title: \<%= h(view.name)%\>

\<%end%\>

Please can someone tell me where the problem is? or is that database  
views are not supported. but i thought they should be mapped just like  
tables.(i may be wrong)  
Has someone else encoured this patriculary while working with a legacy  
database like am doing?

rgds  
Tanzanite

---

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [March 6, 2007, 4:32am UTC](https://www.ruby-forum.com/t/runtimeerror-error-c42p01-mrelation/87809/2 "2007-03-06T04:32:37Z")

</div>

On 5-Mar-07, at 9:49 PM, Tanzanite T. wrote:

> database server.i have over 50 database views which ithought rails  
> would  
> support, just like tables.

> 

I haven’t used rails with postgres views, but this wiki article may  
help you along:

[http://wiki.rubyonrails.org/rails/pages/HowtoUsePostgresViewsAsTables](http://wiki.rubyonrails.org/rails/pages/HowtoUsePostgresViewsAsTables)

plus this article show how views can be used for R, but no CUD. mmmm.  
chew. mmmm.

[http://johnwilger.com/2005/9/29/class-table-inheritance-in-rails-with-](http://johnwilger.com/2005/9/29/class-table-inheritance-in-rails-with-)  
postgresql

cheers,  
Jodi

---

<div class="post-metadata">

**Author:** ![georgeuoa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7ab992/32.png) [@georgeuoa](https://www.ruby-forum.com/u/georgeuoa)\
**Post date:** [March 6, 2007, 4:39am UTC](https://www.ruby-forum.com/t/runtimeerror-error-c42p01-mrelation/87809/3 "2007-03-06T04:39:37Z")

</div>

On 5-Mar-07, at 9:49 PM, Tanzanite T. wrote:

> database server.i have over 50 database views which ithought rails  
> would  
> support, just like tables.
> 
> This is what i have done;  
> i installed the gem rails\_sql\_views which is supposed to among many  
> other things.
> 
> # Implement view support for: MySQL and PostgreSQL
> 
> # Unit tests included

> rgds  
> Tanzanite

yep. didn’t read that bit about the plugin you’re using. yikes.

might want to verify it’s compatibility with your version of rails -  
plus you could also go to trunk to see if it works closer to the edge.

Jodi
