Question

I'm using the Rails 3 Vestal Versions gem: https://github.com/lailsonbm/vestal_versions

I'd like to create some logic to determine if/when to create a new version on a model update. Per the specs, I did:

class Note < ActiveRecord::Base
    versioned :if => :really_create_a_version?

  def really_create_a_version
    Rails.logger.debug 'really_create_a_version really_create_a_version really_create_a_version really_create_a_version - START'
    record.inspect
    @note = Note.find(32)
    Rails.logger.debug 'really_create_a_version really_create_a_version really_create_a_version really_create_a_version - END'
  end

end

But that doesn't work, I get the following error:

NoMethodError (undefined method `really_create_a_version?' for #<Note:0x155c39a28>):
  app/controllers/notes_controller.rb:124:in `update'

Any suggestions or ideas? thxs

UPDATE

Conditional version creation. The versioned method now accepts :if and :unless options. Each expects a symbol representing an instance method or a proc that will be evaluated to determine whether or not to create a new version after an update. An array containing any combination of symbols and procs can also be given. class User < ActiveRecord::Base versioned :if => :really_create_a_version? end

Was it helpful?

Solution

Define your method like this

def really_create_a_version?

You are missing the trailing ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top