Library which adds SQL Views to Rails. Adds create_view and drop_view to the ActiveRecord::ConnectionAdapters::AbstractAdapter (which makes them available to migrations) and adds support for dumping views in the ActiveRecord::SchemaDumper.
Add to your Gemfile:
# Gemfile
gem 'rails_sql_views', :git => "git://github.com/NDrive/rails_sql_views.git"
You can then use create_view and drop_view in your migrations. For example:
class CreatePersonView < ActiveRecord::Migration
def self.up
create_view :v_people, "select * from people" do |t|
t.column :id
t.column :name
t.column :social_security
end
end
def self.down
drop_view :v_people
end
end
This extension also adds support for views in the ActiveRecord::SchemaDumper class.
This fork has been tested on the following databases only:
- SQLite
- SQLite3
- PostgreSQL (Native and Pure Ruby)
- Drivers not mentioned above are not supported.
- Open an issue
- Fork and PR
- tweet @locks