Skip to content
This repository

add instructions to connect to different database #2

Merged
merged 1 commit into from over 1 year ago

2 participants

Peter Zhang Peterpengnz
Peter Zhang

change_logs can save all transactions into separate database 

Peter Zhang add instructions to connect to different database
change_logs can save all transactions into separate database 
03b19a6
Peterpengnz peterzatncs merged commit 71252a1 into from December 19, 2012
Peterpengnz peterzatncs closed this December 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 20, 2012
Peter Zhang add instructions to connect to different database
change_logs can save all transactions into separate database 
03b19a6
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 29 additions and 10 deletions. Show diff stats Hide diff stats

  1. 39  README.textile
39  README.textile
Source Rendered
@@ -116,22 +116,41 @@ ChangeLogs.find(:all,:conditions=>['user = ?', 'peterz'])</code></pre>
116 116
 <pre><code># List all changes for table 'accounts'
117 117
 ChangeLogs.find(:all,:conditions=>['table_name = ?', 'accounts'])</code></pre>   
118 118
 
119  
-* Note: 
120  
-        It is ok if you want to use other table name instead of 'change_logs',
121  
-        choose your preferred table name and run the migration.
122  
-        Just remember in your environment.rb file, you need to tell change_log gem 
123  
-        what is your table name:
  119
+    4. *Turn ChangeLogs off in testing environment*
  120
+You can globally turn it off for your testing.
  121
+<pre><code># config/environment.rb
  122
+ChangeLog.enabled = false if RAILS_ENV == 'test'
  123
+</code></pre>
  124
+
  125
+    5. *Database and table name
  126
+'change_log' can save changes into separate database from the main application. It could be MySQL, SQLite or any other
  127
+database that active record is happy to connect with.
  128
+
  129
+Here is an example of database.yml when using separate database for 'change_logs':
  130
+<pre><code>change_logs:
  131
+  adapter: mysql2
  132
+  encoding: utf8
  133
+  database: change_logs
  134
+  username: username
  135
+  password: ********
  136
+  host: hostname
  137
+  port: 3306
  138
+</code></pre>
124 139
 
  140
+And also you need to tell 'change_logs' to establish the connection.
125 141
 <pre><code># config/environment.rb
126  
-ChangeLogs.set_table_name('hr_maintenances')
  142
+ChangeLogs.establish_connection(:change_logs)
127 143
 </code></pre>
128 144
 
129  
-    4. *Turn ChangeLogs off in testing environment*
130  
-You can globally turn it off for your testing.
  145
+Table name is also configurable. Instead of 'change_logs', choose your preferred table name and run the migration.
  146
+Just remember in your environment.rb file, you need to tell change_log gem 
  147
+what is your table name:
  148
+
131 149
 <pre><code># config/environment.rb
132  
-ChangeLog.enabled = false if RAILS_ENV == 'test'
  150
+ChangeLogs.set_table_name('hr_maintenances')
133 151
 </code></pre>
134 152
 
  153
+
135 154
 h2. Wish List
136 155
     Please email me if you have any enquiry.
137 156
 
@@ -142,4 +161,4 @@ h3. Author
142 161
 Peter Zhang at NCS New Zealand.
143 162
 Email: peterz@ncs.co.nz
144 163
 
145  
-Copyright (c) 2011 Peter Zhang and NCS LTD, released under the MIT license
  164
+Copyright (c) 2011 Peter Zhang and NCS LTD, released under the MIT license
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.