Hi,
So I read about how acts_as_versioned doesn’t play so well with the
latest Rails version.
I got hold of an alternative, version_fu, but I am still having
trouble. GitHub - jmckible/version_fu: Rails 3 update of acts_as_versioned
I’m getting the following error when trying to save the versioned
model:
type = StatisticType.find(1)
type.name = ‘bob’
=> “bob”
type.save
NoMethodError: undefined methodversion=' for #<StatisticType::Version:0x244c3a0> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/attribute_methods.rb:251:in
method_missing’
from /Users/samueljoseph/Code/eclipse-workspace/iknow_reporting/
vendor/plugins/version_fu/lib/version_fu.rb:101:in
instatiate_revision' from /Users/samueljoseph/Code/eclipse-workspace/iknow_reporting/ vendor/plugins/version_fu/lib/version_fu.rb:85:in
check_for_new_version’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
active_support/callbacks.rb:173:insend' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ active_support/callbacks.rb:173:in
evaluate_method’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
active_support/callbacks.rb:161:incall' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ active_support/callbacks.rb:93:in
run’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
active_support/callbacks.rb:92:ineach' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ active_support/callbacks.rb:92:in
send’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
active_support/callbacks.rb:92:inrun' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/ active_support/callbacks.rb:272:in
run_callbacks’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/
active_record/callbacks.rb:298:incallback' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/callbacks.rb:206:in
create_or_update’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/
active_record/base.rb:2211:insave_without_validation' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/validations.rb:911:in
save_without_dirty’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/
active_record/dirty.rb:75:insave_without_transactions' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/transactions.rb:106:in
save’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/
active_record/connection_adapters/abstract/database_statements.rb:
66:intransaction' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/transactions.rb:79:in
transaction’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/
active_record/transactions.rb:98:intransaction' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/transactions.rb:106:in
save’
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/
active_record/transactions.rb:118:inrollback_active_record_state!' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/ active_record/transactions.rb:106:in
save’
Here’s the migration I used to prepare things (I checked in the
database to make sure the changes are there):
class AddStatisticTypeVersioning < ActiveRecord::Migration
def self.up
create_table :statistic_type_versions do |t|
t.integer :statistic_type_id, :statistic_category_id
t.string :name, :time_filter, :unit
t.text :sql
t.timestamps
end
add_column :statistic_types, :version, :integer, :default=>1
end
def self.down
remove_column :statistic_types, :version
drop_table :statistic_type_versions
end
end
Am I making some simple mistake?
Many thanks in advance
CHEERS> SAM