action-audit 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +29 -0
- data/CODE_OF_CONDUCT.md +25 -0
- data/LICENSE +21 -0
- data/README.md +232 -0
- data/Rakefile +12 -0
- data/docs/README.md +25 -0
- data/docs/api-reference.md +434 -0
- data/docs/configuration.md +230 -0
- data/docs/examples.md +609 -0
- data/docs/installation.md +114 -0
- data/docs/migration.md +571 -0
- data/docs/multi-engine.md +413 -0
- data/docs/troubleshooting.md +577 -0
- data/docs/usage.md +347 -0
- data/lib/action-audit.rb +3 -0
- data/lib/action_audit/audit_messages.rb +73 -0
- data/lib/action_audit/engine.rb +19 -0
- data/lib/action_audit/version.rb +5 -0
- data/lib/action_audit.rb +75 -0
- data/lib/generators/action_audit/install_generator.rb +25 -0
- data/lib/generators/action_audit/templates/README +25 -0
- data/lib/generators/action_audit/templates/action_audit.rb +17 -0
- data/lib/generators/action_audit/templates/audit.yml +30 -0
- data/sig/action_audit.rbs +4 -0
- metadata +146 -0
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
Common issues and solutions when using ActionAudit.
|
|
4
|
+
|
|
5
|
+
## Installation Issues
|
|
6
|
+
|
|
7
|
+
### Gem Not Loading
|
|
8
|
+
|
|
9
|
+
**Problem:** ActionAudit module is not available after installation.
|
|
10
|
+
|
|
11
|
+
**Symptoms:**
|
|
12
|
+
```ruby
|
|
13
|
+
NameError: uninitialized constant ActionAudit
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Solutions:**
|
|
17
|
+
1. **Check Gemfile:** Ensure ActionAudit is properly added to your Gemfile:
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'action_audit'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. **Run bundle install:** Make sure you've installed the gem:
|
|
23
|
+
```bash
|
|
24
|
+
bundle install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
3. **Restart Rails server:** Some changes require a server restart:
|
|
28
|
+
```bash
|
|
29
|
+
rails server
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
4. **Check Rails version compatibility:** ActionAudit requires Rails 6.0+:
|
|
33
|
+
```bash
|
|
34
|
+
rails --version
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Generator Not Found
|
|
38
|
+
|
|
39
|
+
**Problem:** Rails generator is not available.
|
|
40
|
+
|
|
41
|
+
**Symptoms:**
|
|
42
|
+
```bash
|
|
43
|
+
Could not find generator 'action_audit:install'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Solutions:**
|
|
47
|
+
1. **Restart Rails console/server:** Generators are loaded at startup
|
|
48
|
+
2. **Check gem installation:** Verify ActionAudit is properly installed:
|
|
49
|
+
```bash
|
|
50
|
+
bundle show action_audit
|
|
51
|
+
```
|
|
52
|
+
3. **Run from Rails root:** Ensure you're in the Rails application directory
|
|
53
|
+
|
|
54
|
+
## Configuration Issues
|
|
55
|
+
|
|
56
|
+
### Audit Messages Not Loading
|
|
57
|
+
|
|
58
|
+
**Problem:** Audit messages from `config/audit.yml` are not being loaded.
|
|
59
|
+
|
|
60
|
+
**Symptoms:**
|
|
61
|
+
- No audit logs appearing
|
|
62
|
+
- `ActionAudit::AuditMessages.lookup` returns `nil`
|
|
63
|
+
|
|
64
|
+
**Debugging Steps:**
|
|
65
|
+
|
|
66
|
+
1. **Check file existence:**
|
|
67
|
+
```bash
|
|
68
|
+
ls -la config/audit.yml
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
2. **Verify YAML syntax:**
|
|
72
|
+
```bash
|
|
73
|
+
ruby -e "require 'yaml'; puts YAML.load_file('config/audit.yml')"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
3. **Check Rails console:**
|
|
77
|
+
```ruby
|
|
78
|
+
# In Rails console
|
|
79
|
+
ActionAudit::AuditMessages.messages
|
|
80
|
+
# Should show your loaded messages
|
|
81
|
+
|
|
82
|
+
ActionAudit::AuditMessages.lookup("users", "create")
|
|
83
|
+
# Should return your configured message
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Common Solutions:**
|
|
87
|
+
- **Fix YAML syntax:** Ensure proper indentation and no tabs
|
|
88
|
+
- **Restart server:** Configuration is loaded at startup
|
|
89
|
+
- **Check file permissions:** Ensure Rails can read the file
|
|
90
|
+
|
|
91
|
+
### Invalid YAML Syntax
|
|
92
|
+
|
|
93
|
+
**Problem:** YAML file has syntax errors.
|
|
94
|
+
|
|
95
|
+
**Symptoms:**
|
|
96
|
+
```
|
|
97
|
+
YAML syntax error in config/audit.yml
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Common YAML Issues:**
|
|
101
|
+
|
|
102
|
+
1. **Tabs instead of spaces:**
|
|
103
|
+
```yaml
|
|
104
|
+
# Wrong (using tabs)
|
|
105
|
+
users:
|
|
106
|
+
create: "Created user"
|
|
107
|
+
|
|
108
|
+
# Correct (using spaces)
|
|
109
|
+
users:
|
|
110
|
+
create: "Created user"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. **Inconsistent indentation:**
|
|
114
|
+
```yaml
|
|
115
|
+
# Wrong
|
|
116
|
+
users:
|
|
117
|
+
create: "Created user"
|
|
118
|
+
update: "Updated user" # Too much indentation
|
|
119
|
+
|
|
120
|
+
# Correct
|
|
121
|
+
users:
|
|
122
|
+
create: "Created user"
|
|
123
|
+
update: "Updated user"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
3. **Missing quotes for special characters:**
|
|
127
|
+
```yaml
|
|
128
|
+
# Wrong
|
|
129
|
+
users:
|
|
130
|
+
create: Message with: colons
|
|
131
|
+
|
|
132
|
+
# Correct
|
|
133
|
+
users:
|
|
134
|
+
create: "Message with: colons"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**YAML Validation:**
|
|
138
|
+
```bash
|
|
139
|
+
# Validate YAML syntax
|
|
140
|
+
ruby -e "require 'yaml'; YAML.load_file('config/audit.yml'); puts 'Valid YAML'"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Runtime Issues
|
|
144
|
+
|
|
145
|
+
### No Audit Logs Appearing
|
|
146
|
+
|
|
147
|
+
**Problem:** Controllers are not logging audit messages.
|
|
148
|
+
|
|
149
|
+
**Symptoms:**
|
|
150
|
+
- Actions execute normally
|
|
151
|
+
- No audit logs in Rails logs
|
|
152
|
+
- No errors thrown
|
|
153
|
+
|
|
154
|
+
**Debugging Checklist:**
|
|
155
|
+
|
|
156
|
+
1. **Check ActionAudit inclusion:**
|
|
157
|
+
```ruby
|
|
158
|
+
# In your controller
|
|
159
|
+
class UsersController < ApplicationController
|
|
160
|
+
include ActionAudit # Make sure this is present
|
|
161
|
+
end
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
2. **Verify message configuration:**
|
|
165
|
+
```ruby
|
|
166
|
+
# Rails console
|
|
167
|
+
ActionAudit::AuditMessages.lookup("users", "create")
|
|
168
|
+
# Should return your configured message, not nil
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
3. **Check controller/action mapping:**
|
|
172
|
+
```ruby
|
|
173
|
+
# For Admin::UsersController, action 'create'
|
|
174
|
+
ActionAudit::AuditMessages.lookup("admin/users", "create")
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
4. **Test logger directly:**
|
|
178
|
+
```ruby
|
|
179
|
+
# Rails console
|
|
180
|
+
Rails.logger.info("Test message")
|
|
181
|
+
# Should appear in logs
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Parameter Interpolation Not Working
|
|
185
|
+
|
|
186
|
+
**Problem:** Audit messages show `%{param}` instead of actual values.
|
|
187
|
+
|
|
188
|
+
**Symptoms:**
|
|
189
|
+
```
|
|
190
|
+
users/create - Created user %{email} # email not interpolated
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Common Causes:**
|
|
194
|
+
|
|
195
|
+
1. **Parameter not in params:**
|
|
196
|
+
```ruby
|
|
197
|
+
# Controller action
|
|
198
|
+
def create
|
|
199
|
+
# If params doesn't contain :email, interpolation fails
|
|
200
|
+
end
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
2. **Wrong parameter name in audit.yml:**
|
|
204
|
+
```yaml
|
|
205
|
+
# audit.yml has %{email} but controller has params[:user_email]
|
|
206
|
+
users:
|
|
207
|
+
create: "Created user %{email}" # Should be %{user_email}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Debugging:**
|
|
211
|
+
```ruby
|
|
212
|
+
# In controller action, add debugging
|
|
213
|
+
def create
|
|
214
|
+
Rails.logger.debug "Params for audit: #{params.inspect}"
|
|
215
|
+
# ... rest of action
|
|
216
|
+
end
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Error Messages in Logs
|
|
220
|
+
|
|
221
|
+
**Problem:** Seeing interpolation error messages in logs.
|
|
222
|
+
|
|
223
|
+
**Symptoms:**
|
|
224
|
+
```
|
|
225
|
+
Created user %{email} (interpolation error: key{email} not found)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Solutions:**
|
|
229
|
+
|
|
230
|
+
1. **Add missing parameters:**
|
|
231
|
+
```ruby
|
|
232
|
+
def create
|
|
233
|
+
@user = User.create!(user_params)
|
|
234
|
+
# Ensure email is available for auditing
|
|
235
|
+
params[:email] = @user.email
|
|
236
|
+
end
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
2. **Update audit message:**
|
|
240
|
+
```yaml
|
|
241
|
+
# Use parameters that are always available
|
|
242
|
+
users:
|
|
243
|
+
create: "Created user with ID %{id}" # id is usually available
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
3. **Use conditional parameters:**
|
|
247
|
+
```yaml
|
|
248
|
+
users:
|
|
249
|
+
create: "Created user %{id}" # Simpler, always works
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Multi-Engine Issues
|
|
253
|
+
|
|
254
|
+
### Engine Configurations Not Loading
|
|
255
|
+
|
|
256
|
+
**Problem:** Audit messages from Rails engines are not being loaded.
|
|
257
|
+
|
|
258
|
+
**Symptoms:**
|
|
259
|
+
- Main app audit messages work
|
|
260
|
+
- Engine-specific messages don't work
|
|
261
|
+
|
|
262
|
+
**Debugging Steps:**
|
|
263
|
+
|
|
264
|
+
1. **Check engine structure:**
|
|
265
|
+
```
|
|
266
|
+
engines/my_engine/
|
|
267
|
+
├── config/
|
|
268
|
+
│ └── audit.yml # Should exist
|
|
269
|
+
└── lib/
|
|
270
|
+
└── my_engine.rb
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
2. **Verify engine mounting:**
|
|
274
|
+
```ruby
|
|
275
|
+
# In main app's routes.rb or engine mounting
|
|
276
|
+
mount MyEngine::Engine, at: '/my_engine'
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
3. **Check Rails console:**
|
|
280
|
+
```ruby
|
|
281
|
+
# List all engines
|
|
282
|
+
Rails.application.railties.each do |railtie|
|
|
283
|
+
puts railtie.class.name if railtie.respond_to?(:root)
|
|
284
|
+
end
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
4. **Test individual engine loading:**
|
|
288
|
+
```ruby
|
|
289
|
+
# Rails console
|
|
290
|
+
ActionAudit::AuditMessages.load_from_file('engines/my_engine/config/audit.yml')
|
|
291
|
+
ActionAudit::AuditMessages.lookup("my_engine/users", "create")
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Configuration Conflicts
|
|
295
|
+
|
|
296
|
+
**Problem:** Multiple engines define the same audit paths.
|
|
297
|
+
|
|
298
|
+
**Symptoms:**
|
|
299
|
+
- Unexpected audit messages
|
|
300
|
+
- Later engines override earlier ones
|
|
301
|
+
|
|
302
|
+
**Example Conflict:**
|
|
303
|
+
```yaml
|
|
304
|
+
# Engine A: config/audit.yml
|
|
305
|
+
users:
|
|
306
|
+
create: "Engine A created user"
|
|
307
|
+
|
|
308
|
+
# Engine B: config/audit.yml
|
|
309
|
+
users:
|
|
310
|
+
create: "Engine B created user" # This overwrites Engine A
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Solutions:**
|
|
314
|
+
|
|
315
|
+
1. **Use namespaced paths:**
|
|
316
|
+
```yaml
|
|
317
|
+
# Engine A
|
|
318
|
+
engine_a:
|
|
319
|
+
users:
|
|
320
|
+
create: "Engine A created user"
|
|
321
|
+
|
|
322
|
+
# Engine B
|
|
323
|
+
engine_b:
|
|
324
|
+
users:
|
|
325
|
+
create: "Engine B created user"
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
2. **Check loading order:**
|
|
329
|
+
```ruby
|
|
330
|
+
# Rails console - see load order
|
|
331
|
+
Rails.application.railties.each_with_index do |railtie, index|
|
|
332
|
+
puts "#{index}: #{railtie.class.name}" if railtie.respond_to?(:config)
|
|
333
|
+
end
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Performance Issues
|
|
337
|
+
|
|
338
|
+
### Slow Application Startup
|
|
339
|
+
|
|
340
|
+
**Problem:** Application takes longer to start after adding ActionAudit.
|
|
341
|
+
|
|
342
|
+
**Symptoms:**
|
|
343
|
+
- Increased Rails startup time
|
|
344
|
+
- Many audit.yml files being loaded
|
|
345
|
+
|
|
346
|
+
**Solutions:**
|
|
347
|
+
|
|
348
|
+
1. **Optimize YAML files:**
|
|
349
|
+
- Remove unused audit messages
|
|
350
|
+
- Combine related messages
|
|
351
|
+
- Use simpler message templates
|
|
352
|
+
|
|
353
|
+
2. **Profile loading:**
|
|
354
|
+
```ruby
|
|
355
|
+
# Add to config/initializers/action_audit.rb
|
|
356
|
+
Rails.logger.info "Loading ActionAudit configurations..."
|
|
357
|
+
start_time = Time.current
|
|
358
|
+
|
|
359
|
+
ActionAudit::AuditMessages.load_from_engines
|
|
360
|
+
|
|
361
|
+
load_time = Time.current - start_time
|
|
362
|
+
Rails.logger.info "ActionAudit loaded in #{load_time}s"
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Memory Usage
|
|
366
|
+
|
|
367
|
+
**Problem:** High memory usage from audit messages.
|
|
368
|
+
|
|
369
|
+
**Symptoms:**
|
|
370
|
+
- Increased Rails memory usage
|
|
371
|
+
- Large audit.yml files
|
|
372
|
+
|
|
373
|
+
**Solutions:**
|
|
374
|
+
|
|
375
|
+
1. **Reduce message complexity:**
|
|
376
|
+
```yaml
|
|
377
|
+
# Instead of long descriptive messages
|
|
378
|
+
users:
|
|
379
|
+
create: "Created user %{email} with full name %{first_name} %{last_name} in department %{department} with role %{role} at %{created_at}"
|
|
380
|
+
|
|
381
|
+
# Use simpler messages
|
|
382
|
+
users:
|
|
383
|
+
create: "Created user %{email}"
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
2. **Remove unused messages:**
|
|
387
|
+
- Audit only important actions
|
|
388
|
+
- Remove debug/development messages in production
|
|
389
|
+
|
|
390
|
+
## Development Issues
|
|
391
|
+
|
|
392
|
+
### Configuration Not Reloading
|
|
393
|
+
|
|
394
|
+
**Problem:** Changes to audit.yml don't take effect in development.
|
|
395
|
+
|
|
396
|
+
**Symptoms:**
|
|
397
|
+
- Modified audit messages don't appear
|
|
398
|
+
- Need to restart server for changes
|
|
399
|
+
|
|
400
|
+
**Solutions:**
|
|
401
|
+
|
|
402
|
+
1. **Check Rails development configuration:**
|
|
403
|
+
```ruby
|
|
404
|
+
# config/environments/development.rb
|
|
405
|
+
config.cache_classes = false # Should be false
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
2. **Manual reload in console:**
|
|
409
|
+
```ruby
|
|
410
|
+
# Rails console
|
|
411
|
+
ActionAudit::AuditMessages.clear!
|
|
412
|
+
ActionAudit::AuditMessages.load_from_engines
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
3. **Restart Rails server:**
|
|
416
|
+
```bash
|
|
417
|
+
# Sometimes necessary for engine changes
|
|
418
|
+
rails server
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Testing Issues
|
|
422
|
+
|
|
423
|
+
**Problem:** Audit messages interfere with tests.
|
|
424
|
+
|
|
425
|
+
**Symptoms:**
|
|
426
|
+
- Unexpected log output in tests
|
|
427
|
+
- Test failures due to audit logging
|
|
428
|
+
|
|
429
|
+
**Solutions:**
|
|
430
|
+
|
|
431
|
+
1. **Configure test environment:**
|
|
432
|
+
```ruby
|
|
433
|
+
# config/environments/test.rb
|
|
434
|
+
config.log_level = :warn # Reduce log noise
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
2. **Disable auditing in tests:**
|
|
438
|
+
```ruby
|
|
439
|
+
# spec/rails_helper.rb or test_helper.rb
|
|
440
|
+
ActionAudit.log_formatter = nil
|
|
441
|
+
ActionAudit.log_tag = nil
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
3. **Stub audit methods:**
|
|
445
|
+
```ruby
|
|
446
|
+
# In specific tests
|
|
447
|
+
before do
|
|
448
|
+
allow_any_instance_of(ApplicationController).to receive(:audit_request)
|
|
449
|
+
end
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## Debugging Tools
|
|
453
|
+
|
|
454
|
+
### Enable Debug Logging
|
|
455
|
+
|
|
456
|
+
```ruby
|
|
457
|
+
# config/initializers/action_audit.rb
|
|
458
|
+
if Rails.env.development?
|
|
459
|
+
ActionAudit.log_formatter = lambda do |controller, action, message|
|
|
460
|
+
debug_info = {
|
|
461
|
+
timestamp: Time.current.iso8601,
|
|
462
|
+
controller: controller,
|
|
463
|
+
action: action,
|
|
464
|
+
message: message,
|
|
465
|
+
params_keys: defined?(params) ? params.keys : 'N/A'
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
Rails.logger.debug "ActionAudit Debug: #{debug_info.inspect}"
|
|
469
|
+
"[DEBUG] #{controller}/#{action} - #{message}"
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Console Helpers
|
|
475
|
+
|
|
476
|
+
```ruby
|
|
477
|
+
# Add to config/initializers/action_audit.rb
|
|
478
|
+
if Rails.env.development?
|
|
479
|
+
module ActionAuditHelpers
|
|
480
|
+
def aa_messages
|
|
481
|
+
ActionAudit::AuditMessages.messages
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def aa_lookup(controller, action)
|
|
485
|
+
ActionAudit::AuditMessages.lookup(controller, action)
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def aa_reload
|
|
489
|
+
ActionAudit::AuditMessages.clear!
|
|
490
|
+
ActionAudit::AuditMessages.load_from_engines
|
|
491
|
+
"ActionAudit messages reloaded"
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
Rails.console do
|
|
496
|
+
include ActionAuditHelpers
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### Test Audit Configuration
|
|
502
|
+
|
|
503
|
+
```ruby
|
|
504
|
+
# Create a test script: test_audit_config.rb
|
|
505
|
+
require_relative 'config/environment'
|
|
506
|
+
|
|
507
|
+
puts "Testing ActionAudit Configuration"
|
|
508
|
+
puts "=" * 40
|
|
509
|
+
|
|
510
|
+
# Test message loading
|
|
511
|
+
messages = ActionAudit::AuditMessages.messages
|
|
512
|
+
puts "Loaded #{messages.size} top-level message groups"
|
|
513
|
+
|
|
514
|
+
# Test specific lookups
|
|
515
|
+
test_cases = [
|
|
516
|
+
['users', 'create'],
|
|
517
|
+
['admin/users', 'create'],
|
|
518
|
+
['sessions', 'destroy']
|
|
519
|
+
]
|
|
520
|
+
|
|
521
|
+
test_cases.each do |controller, action|
|
|
522
|
+
message = ActionAudit::AuditMessages.lookup(controller, action)
|
|
523
|
+
status = message ? "✓" : "✗"
|
|
524
|
+
puts "#{status} #{controller}/#{action}: #{message || 'NOT FOUND'}"
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
# Test parameter interpolation
|
|
528
|
+
test_message = "Created user %{email} with role %{role}"
|
|
529
|
+
test_params = { email: 'test@example.com', role: 'admin' }
|
|
530
|
+
|
|
531
|
+
begin
|
|
532
|
+
interpolated = test_message % test_params.symbolize_keys
|
|
533
|
+
puts "✓ Interpolation test: #{interpolated}"
|
|
534
|
+
rescue => e
|
|
535
|
+
puts "✗ Interpolation failed: #{e.message}"
|
|
536
|
+
end
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Run with: `ruby test_audit_config.rb`
|
|
540
|
+
|
|
541
|
+
## Getting Help
|
|
542
|
+
|
|
543
|
+
If you're still experiencing issues:
|
|
544
|
+
|
|
545
|
+
1. **Check the logs:** Enable debug logging and examine Rails logs
|
|
546
|
+
2. **Review configuration:** Use the debugging tools above
|
|
547
|
+
3. **Create minimal reproduction:** Strip down to simplest failing case
|
|
548
|
+
4. **Check GitHub issues:** Search for similar problems
|
|
549
|
+
5. **Open an issue:** Provide full error messages and configuration
|
|
550
|
+
|
|
551
|
+
## Common Error Messages
|
|
552
|
+
|
|
553
|
+
### `uninitialized constant ActionAudit`
|
|
554
|
+
- **Cause:** Gem not properly installed or loaded
|
|
555
|
+
- **Solution:** Check Gemfile, run `bundle install`, restart server
|
|
556
|
+
|
|
557
|
+
### `undefined method 'audit_request'`
|
|
558
|
+
- **Cause:** ActionAudit not included in controller
|
|
559
|
+
- **Solution:** Add `include ActionAudit` to controller
|
|
560
|
+
|
|
561
|
+
### `YAML syntax error`
|
|
562
|
+
- **Cause:** Invalid YAML in audit.yml file
|
|
563
|
+
- **Solution:** Validate YAML syntax, fix indentation issues
|
|
564
|
+
|
|
565
|
+
### `key{param} not found`
|
|
566
|
+
- **Cause:** Parameter referenced in audit message not available in controller params
|
|
567
|
+
- **Solution:** Ensure parameter exists or update audit message
|
|
568
|
+
|
|
569
|
+
### `undefined method 'tagged'`
|
|
570
|
+
- **Cause:** Logger doesn't support tagging (rare)
|
|
571
|
+
- **Solution:** Set `ActionAudit.log_tag = nil` or use custom logger
|
|
572
|
+
|
|
573
|
+
## Next Steps
|
|
574
|
+
|
|
575
|
+
- [Check the API reference](api-reference.md)
|
|
576
|
+
- [See migration guide](migration.md)
|
|
577
|
+
- [Return to main documentation](README.md)
|