danielfone / as_csv

Instant CSV support for Rails
MIT License
19 stars 9 forks source link

Version 3 does not work in Rails 7 #12

Closed gstokkink closed 1 year ago

gstokkink commented 1 year ago

Hi,

First of all, thanks for your work on this gem!

I have noticed that since version 3, the gem is no longer loaded correctly for Rails 7 at least. I had to downgrade to 2.0.2 to have access to the as_csv method on my records. Looks like the railtie is not functioning correctly?

danielfone commented 1 year ago

Hi @gstokkink! I'm surprised to hear you're having an issue with Rails 7. Version 3 is intended to support Rails 7 and it is tested with it. Can you give some more details so I can try to reproduce the issue?

gstokkink commented 1 year ago

I basically upgraded my application to Rails 7 and the gem to version 3, and the as_csv method was no longer defined for any ActiveRecord instance. Note that as_json still worked perfectly.

danielfone commented 1 year ago

@gstokkink which version of Ruby are you using, and which specific version of Rails? I'll see if I can reproduce.

gstokkink commented 1 year ago

@danielfone I am using Ruby 2.7.5 and Rails 7.0.4.2 (latest)

danielfone commented 1 year ago

@gstokkink, thanks. Can you try the improve-railtie branch locally to see if it fixes it? If so, I'll tidy it up and release a new version. I'm actually inclined to release a new major version that does away with the monkey patching entirely — it's a bit fragile.

Edit for convenience: I think this should work in your Gemfile

gem "as_csv", github: "danielfone/as_csv", branch: "improve-railtie"
gstokkink commented 1 year ago

@danielfone that seems to work! I can call to_csv on AR objects and relations.

danielfone commented 1 year ago

@gstokkink I've just released v3.0.1. I'm closing this issue, but feel free to reopen if anything is amiss!