Project

views

0.0
No commit activity in last 3 years
No release in over 3 years
Simple way to manage database views in rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 1.1
~> 0.18

Runtime

< 4.3.0, >= 4.2.0
 Project Readme

Gem Version Code Climate Build Status Dependency Status

Views

Simple way to manage database views in rails.

Why

I did this gem to:

  • Keep views definitions into separate sql files without versioning.
  • Register views into schema.
  • Control views from migrations.

Install

Put this line in your Gemfile:

gem 'views'

Then bundle:

$ bundle

Usage

Definitions

To generate a view:

$ bundle exec rails g view guitars

Edit the generated sql file db/views/guitars.sql:

SELECT
  products.*
WHERE
  products.category = 'Guitar'

Run the migration:

$ bundle exec rake db:migrate

Modifications

If you need to make a change, update the sql and run a migration with:

class ChangeGuitarsView < ActiveRecord::Migration
  def change
    change_view :guitars
  end
end

If you want to drop it:

class DropGuitarsView < ActiveRecord::Migration
  def change
    drop_view :guitars
  end
end

Contributing

Any issue, pull request, comment of any kind is more than welcome!

I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD. 

Credits

This gem is maintained and funded by mmontossi.

License

It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.