# Undefined Method 'views'

**URL:** <https://www.ruby-forum.com/t/undefined-method-views/129527>\
**Category:** Rails\
**Created:** [February 19, 2008, 10:44am UTC](https://www.ruby-forum.com/t/undefined-method-views/129527 "2008-02-19T10:44:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a87d85/32.png) [@lgas](https://www.ruby-forum.com/u/lgas)\
**Post date:** [February 19, 2008, 10:44am UTC](https://www.ruby-forum.com/t/undefined-method-views/129527/1 "2008-02-19T10:44:29Z")

</div>

Hi,

I have installed rails\_sql\_views-0.1.0.gem in jruby\bin directory.

I referred this link  
[http://activewarehouse.rubyforge.org/rails\_sql\_views/](http://activewarehouse.rubyforge.org/rails_sql_views/)  
to create a database view

Code to create a view

class CreateViews \< ActiveRecord::Migration  
def self.up  
create\_view(:v\_photo, “select description, content\_type from photo”)  
do |t|  
t.column :description  
t.column :content\_type  
end  
end

def self.down  
drop\_view(:v\_photo)  
end  
end

I got the view created successfully, and also got this error

# E:\Work\JRuby\MyApp\>jruby --command rake environment RAILS\_ENV=development\_postg res db:migrate (in E:/Work/JRuby/MyApp) == CreateViews: migrating

# – create\_view(:v\_photo, “select description, content\_type from photo”) → 0.7830s == CreateViews: migrated (0.7830s)

rake aborted!  
undefined method `views’ for  
#\<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x1  
bdcbb2 @last\_verification=0, @runtime=0, @config={:password=\>nil,  
:driver=\>“org.  
postgresql.Driver”, :adapter=\>“jdbc”, :username=\>“efipgsql”,  
:allow\_concurrency=

> false, :url=\>“jdbc:postgresql://localhost:5432/MyApp”}, @connection=#\<ActiveRec  
> ord::ConnectionAdapters::JdbcConnection:0x1756db3  
> @native\_types={:datetime=\>{:na  
> me=\>“timestamp”}, :text=\>{:name=\>“text”},  
> :timestamp=\>{:name=\>“timestamp”}, :boo  
> lean=\>{:name=\>“bool”, :limit=\>1}, :time=\>{:name=\>“time”},  
> :date=\>{:name=\>“date”}  
> , :decimal=\>{:name=\>“numeric”, :limit=\>9}, :string=\>{:name=\>“varchar”,  
> :limit=\>9  
> }, :float=\>{:name=\>“float4”}, :binary=\>{:name=\>“bytea”},  
> :integer=\>{:name=\>"int4  
> ", :limit=\>9}}, @config={:password=\>nil,  
> :driver=\>“org.postgresql.Driver”, :adap  
> ter=\>“jdbc”, :username=\>“efipgsql”, :allow\_concurrency=\>false,  
> :url=\>“jdbc:postg  
> resql://localhost:5432/MyApp”}, @stmts={},  
> @tps={:datetime=\>{:name=\>“timestamp”}  
> , :boolean=\>{:name=\>“bool”, :limit=\>nil},  
> :timestamp=\>{:name=\>“timestamp”}, :tex  
> t=\>{:name=\>“text”}, :date=\>{:name=\>“date”}, :time=\>{:name=\>“time”},  
> :decimal=\>{:  
> name=\>“numeric”, :limit=\>9}, :primary\_key=\>“serial primary key”,  
> :float=\>{:name=  
> “float4”}, :string=\>{:name=\>“varchar”, :limit=\>255}, :binary=\>{:name=\>“bytea”},  
> :integer=\>{:name=\>“int4”, :limit=\>nil}},  
> @connection=#\<Java::OrgPostgresqlJdbc3  
> ::Jdbc3Connection:0x121ea24  
> @java\_object=org.postgresql.jdbc3.Jdbc3Connection@18  
> fa85\>,  
> @adapter=#\<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x1bdcbb2  
> …\>\>,  
> @logger=#\<Logger:0x192e317 @logdev=#\<Logger::LogDevice:0x7b0f4d  
> @filename=“E:/W  
> ork/JRuby/MyApp/config/…/log/development\_postgres.log”,  
> @mutex=#\<Logger::LogDev  
> ice::LogDeviceMutex:0x12996d6 @mon\_count=0, @mon\_owner=nil,  
> @mon\_waiting\_queue=[  
> ], @mon\_entering\_queue=[]\>, @shift\_age=0,  
> @dev=#\<File:E:/Work/JRuby/MyApp/config  
> /…/log/development\_postgres.log\>, @shift\_size=1048576\>, @formatter=nil,  
> @progna  
> me=nil, @default\_formatter=#\<Logger::Formatter:0x27de24  
> @datetime\_format=nil\>, @  
> level=0\>\>

Appreciate your help !!

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![lgas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a87d85/32.png) [@lgas](https://www.ruby-forum.com/u/lgas)\
**Post date:** [February 20, 2008, 6:29am UTC](https://www.ruby-forum.com/t/undefined-method-views/129527/2 "2008-02-20T06:29:23Z")

</div>

Any solution to fix this error?

Thanks,  
John

John E. wrote:

> Hi,
> 
> I have installed rails\_sql\_views-0.1.0.gem in jruby\bin directory.
> 
> I referred this link  
> [http://activewarehouse.rubyforge.org/rails\_sql\_views/](http://activewarehouse.rubyforge.org/rails_sql_views/)  
> to create a database view
> 
> Code to create a view
> 
> class CreateViews \< ActiveRecord::Migration  
> def self.up  
> create\_view(:v\_photo, “select description, content\_type from photo”)  
> do |t|  
> t.column :description  
> t.column :content\_type  
> end  
> end
> 
> def self.down  
> drop\_view(:v\_photo)  
> end  
> end
> 
> I got the view created successfully, and also got this error
> 
> # E:\Work\JRuby\MyApp\>jruby --command rake environment RAILS\_ENV=development\_postg res db:migrate (in E:/Work/JRuby/MyApp) == CreateViews: migrating
> 
> # – create\_view(:v\_photo, “select description, content\_type from photo”) → 0.7830s == CreateViews: migrated (0.7830s)
> 
> rake aborted!  
> undefined method `views’ for  
> #\<ActiveRecord::ConnectionAdapters::JdbcAdapter:0x1 …  
> …

> Appreciate your help !!
> 
> Thanks,  
> John

---

<div class="post-metadata">

**Author:** ![lgas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a87d85/32.png) [@lgas](https://www.ruby-forum.com/u/lgas)\
**Post date:** [January 5, 2009, 7:28pm UTC](https://www.ruby-forum.com/t/undefined-method-views/129527/3 "2009-01-05T19:28:34Z")

</div>

John E. wrote:

> Any solution to fix this error?
> 
> Thanks,  
> John

put this in environment.rb:

require ‘rails\_sql\_views’  
gem ‘rails\_sql\_views’
