No commit activity in last 3 years
No release in over 3 years
Missing rails 4 database generator that I needed
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3

Runtime

~> 4
 Project Readme

Rails_g_database

Missing rails database generator (now supporting rails 4) I have found many and many tutorials how to use more than one DB with Ruby on Rails finally I found THIS gist forked from rafaelchiti that I believe is the right one and works for me the best :) I am still using multiple appplications with more databases, so I thought this would ease my pain :)

Installation

Add this line to your application's Gemfile (this way you get the most recent one):

gem 'rails_g_database'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_g_database

Usage

For now it lacks comments, but is functional for me :) here is the way to use it:

rails g database NAME adapter:adapter_name db:database_name login:username psswd:password host:host_name port:port_number

NAME

name your database here (also applies on directory names and so on ...)

adapter

for now it supports:

  • MySQL (as 'mysql')
  • PostgreSQL (as 'pg')
  • SQLite (as 'sqlite')

db

you can change the name of your database othervise it falls back to the NAME of your db (in most cases leave blank :) )

login

except sqlite, you can specify your DB credentials (this one stand for username)

psswd

except sqlite, you can specify your DB credentials (this one stands for password)

host

except sqlite, you can specify your DB credentials (this one stands for host, in most cases localhost)

port

except sqlite, you can specify your DB credentials (this one stands for port, in case of postgresql 5432)

After generating all files we need, basically what you have to do is not to inherit from Activerecord::Base, but from newly created NAME::Base and there you go, you are working with another database :)

More info is on the way ...

Thanks

To rafaelchiti for his README that solved my problems

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Bitdeli Badge