Vestal_versions -- can I set it to ignore certain columns?

I’d like my published boolean to be excluded from the calculation as
to whether a version is created or not. Can anyone suggest a way to do
that?

Thanks,

Walter

On Sep 16, 10:04 am, Walter Lee D. [email protected] wrote:

I’d like my published boolean to be excluded from the calculation as
to whether a version is created or not. Can anyone suggest a way to do
that?

Digging into the code a bit, it appears you can specify options to
ignore certain columns.

In lib / vestal_versions / creation.rb,
# Returns an array of column names that should be included in
the changes of created
# versions. If vestal_versions_options[:only] is
specified, only those columns
# will be versioned. Otherwise, if
vestal_versions_options[:except] is specified,
# all columns will be versioned other than those specified.
Without either option, the
# default is to version all columns. At any rate, the four
“automagic” timestamp columns
# maintained by Rails are never versioned.
def versioned_columns
case
when vestal_versions_options[:only] then
self.class.column_names & vestal_versions_options[:only]
when vestal_versions_options[:except] then
self.class.column_names - vestal_versions_options[:except]
else self.class.column_names
end - %w(created_at created_on updated_at updated_on)
end

Thanks, that’s really helpful, but I’m not sure how to pass this on to
vestal_versions. I’ve tried all manner of arguments to the versioned
command, is that not the right place to do this?

class Page < ActiveRecord::Base
versioned :options => {:except => :publish}

(also tried just :except => ‘publish’, bunch of variations on that
theme…)

I’m using version 0.8.0 if that makes any difference.

Thanks in advance,

Walter

I’m looking through the versions on Github – and it looks like the
latest versions might have this, while my older version does not. Gem
refuses to update me further than this point, probably because I’m
stuck on Ruby 1.8.6 on this machine.

Walter

This is crazy. The version jump from 1.0.1 to 1.0.2 includes a
dependency on Ruby 1.8.7, which I don’t have. I did manage to update
to 1.0.1, we’ll see if this works now…

Walter

Finally figured it out. Updating the gem meant a significant change in
the database, as well as a method I had been using becoming protected.
After a bit of hacking and swearing, I have the desired result.
Checking the Publish control no longer forces a new version. Thanks
for your help!

Walter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs