This is a demo for Comma issue #113
- Clone the repository
- Run
rails server -b 0.0.0.0
- Go to http://localhost:3000/audits.csv
- Get the error
Optional verification:
- Update the Gemfile to use version 4.2.0
- Restart the server and go to http://localhost:3000/audits.csv
- See it is downloading a CSV as expected
This demo was created by following these steps:
$ rails new comma-bug --database=sqlite3 --skip-yarn --skip-action-mailer \
--skip-active-storage --skip-action-cable --skip-sprockets --skip-spring \
--skip-listen --skip-coffee --skip-javascript --skip-turbolinks \
--skip-test --skip-system-test --skip-bootsnap
# Gemfile
gem 'comma'
gem 'audited' # this gem uses polymorphic associations
$ rails g scaffold user name:string email:string
$ rails db:migrate
$ rails generate audited:install
$ rails db:migrate
Note that the error is caused by this piece of code:
# app/models/audit.rb
class Audit < Audited.audit_class
comma do
id
version
created_at
auditable_id
auditable_type
action
user_id
audited_changes
# These lines are the ones causing the error
# - Without them, the CSV generation works
# - With them, and with comma 4.2.0, the CSV generation works
auditable identity: 'Auditable name'
user name: 'User name'
end
end
- Go to http://localhost:3000/audits.csv
- And get the error
Polymorphic association does not support to compute class.