Skip to content

create/update/destroy can now have custom events#174

Merged
batter merged 1 commit intopaper-trail-gem:masterfrom
fanta:custom_events
May 13, 2013
Merged

create/update/destroy can now have custom events#174
batter merged 1 commit intopaper-trail-gem:masterfrom
fanta:custom_events

Conversation

@fanta
Copy link
Copy Markdown
Contributor

@fanta fanta commented Oct 8, 2012

I allows you to have custom events, this is useful when you want to track specific changes with a specific name, let's say that you have a model 'Sale' with some fields like 'price' 'sale_price', and you want to use an specific event when the 'price' changes, so you use something like:

class Sale
  before_update :set_custom_event
  has_paper_clip

  private
  def set_custom_event
    self.custom_event = 'price_changed' if price_changed?
  end
end

@JeanMertz
Copy link
Copy Markdown

This seems like a cool feature, although the custom_event attribute seems awfully generic, no?

I'd vote for paper_trail_event

@ghost ghost assigned batter May 13, 2013
@batter batter merged commit 0347195 into paper-trail-gem:master May 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants