I'm just wondering how to implement database views in Ruby on Rails. Can you guys put some working example? And thank you for every advises and examples.
A:
There is this plugin, untested.
I have never used database views, and I believe is not something that Rails developer have to use often either, probably because violates the MVC pattern.
Chubas
2010-07-15 04:22:39
+3
A:
You mean client-side views on the database or views within the database?
Most relational databases support views which encapsulate a projection or other set-based operation into a virtual table:
CREATE VIEW viewname AS
SELECT *
,some_derived_column
FROM basetable
WHERE some_filter_criteria
Rails typically uses a pattern called Active Record to map database tables/views into Ruby for access at that layer. How you deal with it at that point is kind of wide open.
Cade Roux
2010-07-15 04:23:05