Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add rails/init.rb and examples/friendly.yml

  • Loading branch information...
commit 181d4af67cce64d45ab4f1b4a6b62fd77fa446e5 1 parent 6d2ffa9
@jamesgolick authored
Showing with 27 additions and 9 deletions.
  1. +17 −9 README.md
  2. +7 −0 examples/friendly.yml
  3. +3 −0  rails/init.rb
View
26 README.md
@@ -93,22 +93,30 @@ Friendly is available as a gem. Get it with:
Setup
=====
-First, you need to instantiate a Sequel database object. Sequel has lots of great docs, but for mysql it looks like this:
+All you have to do is supply Friendly with some information about your database:
- $db = Sequel.connect "mysql://user@server/db_name"
+ Friendly.configure :adapter => "mysql",
+ :host => "localhost",
+ :user => "root",
+ :password => "swordfish",
+ :database => "friendly_development"
-Then, setup the friendly datastore object:
+Now, you're ready to rock.
- Friendly.datastore = Friendly::DataStore.new($db)
+If you're using rails, set friendly as a gem dependency:
-Now, you're ready to rock.
+ config.gem "friendly"
-If you're using rails, create a file called config/initializers/friendly.rb and put something like this in it:
+...and drop something like this in config/friendly.yml:
- $db = Sequel.connect "mysql://user@server/db_name"
- Friendly.datastore = Friendly::DataStore.new($db)
+ development:
+ :adapter: "mysql"
+ :host: "localhost"
+ :user: "root"
+ :password: "swordfish"
+ :database: "friendly_development"
-Of course, you'll want to replace user@server/db_name with values that are appropriate for your system. Ultimately, you'll probably want to add a config file, so that your production environment can differ from development and so forth. I will include something like this in a future version of Friendly.
+Of course, you'll want to swap out these values for your own, fill in additional environments, and so forth.
TODO
====
View
7 examples/friendly.yml
@@ -0,0 +1,7 @@
+development:
+ :adapter: "mysql"
+ :host: "localhost"
+ :user: "root"
+ :password: "swordfish"
+ :database: "friendly_development"
+
View
3  rails/init.rb
@@ -0,0 +1,3 @@
+config = YAML.load(File.read(RAILS_ROOT + "/config/friendly.yml"))[RAILS_ENV]
+Friendly.configure(config)
+
Please sign in to comment.
Something went wrong with that request. Please try again.