model 是对应数据库中一张表的!
如何让 model 对应到数据库中的一张视图?有什么好用的 gem 吗?
Enterprise Rails 有一章专门讲这个的,可以在 Google Books 上看到这一章
#1 楼 @nightire
我是把 view 直接当成 table 处理的,但会报如下错误
ActiveRecord::ConnectionAdapters::OracleEnhancedConnectionException ("DESC V_USERS" failed; does it exist?): C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:76:in `describe' C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:213:in `describe' C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1074:in `columns_without_cache' C:/RailsInstaller/Ruby1.8.7/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1065:in `columns'
貌似会来解析我的表结构
怀疑是不是 view 的权限问题。回去再看下
解决了,如果视图的所有者不是本用户的话,需要 set_table_name 中增加视图所有者。如 SYSTEM.V_USERS