Permalink
Browse files

Merge pull request #2 from peterpengnz/patch-2

add instructions to connect to different database
  • Loading branch information...
2 parents 38bc034 + 03b19a6 commit 71252a1de8ed3334f48ac0e245ad702d849db28c @peterzatncs peterzatncs committed Dec 19, 2012
Showing with 29 additions and 10 deletions.
  1. +29 −10 README.textile
View
@@ -116,22 +116,41 @@ ChangeLogs.find(:all,:conditions=>['user = ?', 'peterz'])</code></pre>
<pre><code># List all changes for table 'accounts'
ChangeLogs.find(:all,:conditions=>['table_name = ?', 'accounts'])</code></pre>
-* Note:
- It is ok if you want to use other table name instead of 'change_logs',
- choose your preferred table name and run the migration.
- Just remember in your environment.rb file, you need to tell change_log gem
- what is your table name:
+ 4. *Turn ChangeLogs off in testing environment*
+You can globally turn it off for your testing.
+<pre><code># config/environment.rb
+ChangeLog.enabled = false if RAILS_ENV == 'test'
+</code></pre>
+
+ 5. *Database and table name
+'change_log' can save changes into separate database from the main application. It could be MySQL, SQLite or any other
+database that active record is happy to connect with.
+
+Here is an example of database.yml when using separate database for 'change_logs':
+<pre><code>change_logs:
+ adapter: mysql2
+ encoding: utf8
+ database: change_logs
+ username: username
+ password: ********
+ host: hostname
+ port: 3306
+</code></pre>
+And also you need to tell 'change_logs' to establish the connection.
<pre><code># config/environment.rb
-ChangeLogs.set_table_name('hr_maintenances')
+ChangeLogs.establish_connection(:change_logs)
</code></pre>
- 4. *Turn ChangeLogs off in testing environment*
-You can globally turn it off for your testing.
+Table name is also configurable. Instead of 'change_logs', choose your preferred table name and run the migration.
+Just remember in your environment.rb file, you need to tell change_log gem
+what is your table name:
+
<pre><code># config/environment.rb
-ChangeLog.enabled = false if RAILS_ENV == 'test'
+ChangeLogs.set_table_name('hr_maintenances')
</code></pre>
+
h2. Wish List
Please email me if you have any enquiry.
@@ -142,4 +161,4 @@ h3. Author
Peter Zhang at NCS New Zealand.
Email: peterz@ncs.co.nz
-Copyright (c) 2011 Peter Zhang and NCS LTD, released under the MIT license
+Copyright (c) 2011 Peter Zhang and NCS LTD, released under the MIT license

0 comments on commit 71252a1

Please sign in to comment.