View on GitHub

Shawn Lindsey

Welcome. I like Ruby/Rails/Javascript.

HOME

Active Record Outside of Rails - Setup

Posted on March 9th, 2016.

Sometimes it's nice to set up Active Record outside of Rails. It's really quite easy.

github.com/slindsey3000/ContactManager

The above repo will get you going fast with Active Record in a Ruby app.
Just...

  1. Clone the repo above with
    > git clone https://github.com/slindsey3000/ContactManager.git
  2. > bundle install
  3. > rake db:migrate RAILS_ENV=production
  4. that's it!

You can look through https://github.com/slindsey3000/ContactManager/blob/master/contact_manager.rb to see where all the action is.

The gem standalone_migrations lets you use normal migrations (like in Rails). This uses a sqlite3 db (but you could use another)

Check out Gemfile in the repo

> ruby contact_manager.rb setup // runs the program for the first time and sets up the DB (see the code)
> ruby contact_manager.rb // runs the program the rest of the time
> contacts L // When the program is running type this in to see it working (real exciting)
> contacts email LisaESauceda@armyspy.com // Type this in to see other 'features' of this program
> exit // will end the program

Really just look through the very small repo to see how it works. Have fun!