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.
1 Answer
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.