Giter Club home page Giter Club logo

comma-gem-bug's Introduction

Comma Bug Demo

This is a demo for Comma issue #113

Usage

  1. Clone the repository
  2. Run rails server -b 0.0.0.0
  3. Go to http://localhost:3000/audits.csv
  4. Get the error

Optional verification:

  1. Update the Gemfile to use version 4.2.0
  2. Restart the server and go to http://localhost:3000/audits.csv
  3. See it is downloading a CSV as expected

Creating this Demo

This demo was created by following these steps:

Step 1. Create a minimal rails app

$ 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

Step 2. Add gem dependencies to Gemfile and run bundle

# Gemfile
gem 'comma'
gem 'audited'   # this gem uses polymorphic associations

Step 3. Scaffold a sample model

$ rails g scaffold user name:string email:string
$ rails db:migrate

Step 4. Install audited

$ rails generate audited:install
$ rails db:migrate

Step 5. Update User model

Step 6. Create a couple of users

Step 7. Create audits model and controller

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

Step 8. Download a CSV

comma-gem-bug's People

Contributors

dannyben avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.