Forum: Ruby on Rails RuntimeError: ERROR C42P01 Mrelation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
George G. (Guest)
on 2007-03-06 04:49
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</h1>

<%for myview in @myviews -%>

        <div class= "entry">
<h3> Title: <%= h(view.name)%> </h3>
        </div>

<%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
Jodi S. (Guest)
on 2007-03-06 05:32
(Received via mailing list)
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/HowtoUsePo...

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-inheri...
postgresql

cheers,
Jodi
Jodi S. (Guest)
on 2007-03-06 05:39
(Received via mailing list)
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
This topic is locked and can not be replied to.