Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Adds soft purging from fastly-ruby client #56

Merged
merged 4 commits into from
Jun 2, 2016
Merged

Conversation

gschorkopf
Copy link
Member

  • Includes soft_purge, soft_purge_all class/instance methods within ActiveRecord. Useful for callbacks, or calling on an instance of an ActiveRecord model

Concerns:

  • Do we want to include same functionality for Mongoid?
  • This all hinges on the fact that the client method is well tested
  • Ideally, I'd rather use keyword args, but that's not very well backwards compatible with old rubies

@@ -1,3 +1,3 @@
module FastlyRails
VERSION = "0.6.0"
VERSION = "0.6.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this a 0.7.0 bump since we are adding new methods now. (I know I said the opposite yesterday but that was before the new features.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, git history updated.

@blithe
Copy link
Contributor

blithe commented Jun 2, 2016

One minor comment about the versioning but this LGTM. 👍

@gschorkopf gschorkopf force-pushed the gschorkopf/soft-purge branch from 6716965 to 2c28c48 Compare June 2, 2016 15:51
@lanej
Copy link
Contributor

lanej commented Jun 2, 2016

👍

@lanej lanej merged commit 8245aa8 into master Jun 2, 2016
@lanej lanej deleted the gschorkopf/soft-purge branch June 2, 2016 16:03
@samratjp
Copy link

samratjp commented Jun 9, 2016

Hey guys!

Thanks for merging this. Previously I was using the ruby client to soft purge and now wanted to take full advantage of the Rails gem and just tried it out with 0.7.0. I tried soft purge on an ActiveRecord model and it didn't work and got this instead:

ArgumentError: wrong number of arguments (2 for 1)
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/fastly-rails-0.7.0/lib/fastly-rails/client.rb:11:in `purge_by_key'
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/fastly-rails-0.7.0/lib/fastly-rails.rb:26:in `purge_by_key'
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/fastly-rails-0.7.0/lib/fastly-rails/active_record/surrogate_key.rb:41:in `soft_purge'
  from (irb):7
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  from /Users/my_username_redacted/.rvm/gems/ruby-2.2.2@maker/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'

I'm on Rails 4.2.4 + Ruby 2.2.2. Fwiw, I was previously doing this before the soft_purge support:

FastlyRails.client.get_service(ENV.fetch("FASTLY_SERVICE_ID")).purge_by_key(some_object.record_key, true) 

Thanks,
Sam

@lanej
Copy link
Contributor

lanej commented Jun 9, 2016

@samratjp let's bring this over to an issue and work it out.

@samratjp samratjp mentioned this pull request Jun 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants