winton / acts_as_archive Goto Github PK
View Code? Open in Web Editor NEWDon't delete your records, move them to a different table
License: MIT License
Don't delete your records, move them to a different table
License: MIT License
Running rails 3.1.3. I'm using this branch:
https://github.com/stipple/acts_as_archive
and having a problem with restoring records on STI tables.
I have a User model, and a Student model that inherits from it. When I attempt to archive a user without a type, it archives and restores fine. When I attempt to archive a Student (i.e. User with type = 'Student'), it archives, but will not restore.
I know that someone had the same issue:
#22
but his fix isn't working for me. Anyone got a recommendation?
$ rails generate active_admin:install
Causes this error on Ruby 1.9.2, Rails 3.1, gem --version 1.8.10
/lib/ruby/gems/1.9.1/gems/psych-1.2.1/lib/psych.rb:157:in `parse': (<unknown>):
couldn't parse YAML at line 1 column 9 (Psych::SyntaxError)
from /opt/ruby/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/psych-1.2.1/lib/psych.rb:157:in `parse_stream'
from /opt/ruby/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/psych-1.2.1/lib/psych.rb:128:in `parse'
from /opt/ruby/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/psych-1.2.1/lib/psych.rb:115:in `load'
from /opt/ruby/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/acts_as_archive-0.4.0/lib/acts_as_archive/gems.rb:66:
in `block in gemset='
Line 49 in acts_as_archive.rb swallows exceptions:
I noticed this when I had problems getting my models to work with acts_as_archive. I found out the models failed to load because the models where using code/plugins that had not yet been loaded when the acts_as_archive initializer was triggered. Line 49 made it difficult to find the problem.
My solution was to move this line all the way to the bottom of Gemfile:
I suggest that "rescue nil" is removed. I can provide a patch if required.
The Destroy
and Rrestore
modules call add_conditions!
which is no longer available in Rails 3
use jruby1.6rc1,rails3.0.1,activerecord-jdbcsqlite3-adapter,in migrate use:
ActsAsArchive.update Post
it show:
AlsoMigrate error: ActiveRecord::JDBCError: near "LIKE": syntax error:
CREATE TABLE archived_posts LIKE posts;
First of all, thanks for this gem. I like the idea behind it and it's working great.
The only thing I haven't been able to figure out is how to handle many-to-many relationships. I have a Reservation class that has_and_belongs_to_many EquipmentPieces.
When a reservation is archived, I want to also archive the corresponding entries in the equipment_pieces_reservations table, but I haven't been able to figure out how to do this.
Thanks again.
class Foo < ActiveRecord::Base
has_many :bar
belongs_to :account
def name
return "#{first_name} #{last_name}"
end
end
Build a foo:
foo = Foo.create(:first_name => "John", :last_name => "Adams", :account_id => 1)
bar = Bar.new
bar.foo = foo
bar.save
foo_id = foo.id
bar_id = bar.id
Now we can call foo.bars & get back the bar created. If we call foo.name, we get "John Adams". If we call foo.account, we get Account with id = 1. If we call foo.destroy, it is moved to the archive table. However, if we now load it as:
foo = Foo::Archive.find(foo_id)
foo.name #NoMethodError: undefined method name' for #<Foo::Archive:0x105ffdcb8> foo.bars #NoMethodError: undefined method
bars' for #Foo::Archive:0x105ffdcb8
foo.account #NoMethodError: undefined method `account' for #Foo::Archive:0x105ffdcb8
Is there any way to archive it in a way that the methods are still maintained? How can we handle relationships, such that they are also maintained?
when using : rails g migration xxx, the created migration will have no more numbering
see my problem here : http://stackoverflow.com/questions/10855883/rails-generate-migration-no-more-version-number-acts-as-archive-compatibility?
I'm using rails 3.2 - ruby 1.9.2 - rvm - mysql
Within the Delete records without archiving section, shouldn't the line
Article::Archive.first.destroy!
be this instead
Article.first.destroy!
Also, is there a Model::Archive#restore
method available? The idea of destroying a destroyed object in order to restore it just doesn't sit well for me. I would have expected it to purge the record from the archive instead.
Great library though! Love how cleanly it integrates.
Apologies if this is a stupid question. I haven't tried to work with a gem before.
I'm trying to use acts_as_archive with JRuby. I'm using mysql, but because it's jruby the adapter is jdbcdriver.
I was hoping that I could just add a condition in tables.rb, and things would work.
I downloaded, tried to run the specs, and it complained about a missing db. I created the db, but now I don't have any tables.
If you could point me in the right direction to get the test suite going, I'd appreciate it.
Steps to reproduce :
ActsAsArchive.update Article
The first migration will fail because acts_as_archive will try to create an index on :status which is not yet available. This could be prevented by testing presence of column before setting indexes, and warn if not available instead of crash the migration.
I'll see what I can do there.
In my model:
class Product < ActiveRecord::Base acts_as_archive end
Error:
ActionController::RoutingError (undefined local variable or method `acts_as_archive' for #< Class:0x000001037b1930 >): app/models/product.rb:1:in `' app/models/product.rb:1:in `' app/controllers/products_controller.rb:1:in `'
Hi,
Excellent gem! Looks like some great work there :)
I am having an issue getting this to work for a model that has a non-standard ID field - I am using a UUID for the ID field (details below).
Seems like the db:migrate process fails to recognise this model and doesn't create it's archive table.
The migration for this model looks like:
...
create_table :components, :id => false do |t|
t.string :uuid, :limit => 36, :null => false
...
end
...
In the model I have...
...
set_primary_key :uuid
attr_readonly :id
before_validation :set_uuid
...
Would you be able to take a look at this issue? Anything more I can do to help?
Thanks,
Jits
Hi,
I have the most recent version of the gem installed and it is working. However, my Rails Console tells me there are 10(!) identical "INSERT INTO archived_my_table ~~~" statements being issued for each delete/archive operation.
Just wondering if this is normal, if anyone else is experiencing the same problem, or if I am just interpreting the output of my Rails Console incorrectly.
Thanks for any insights on this issue,
Larry
I just added acts_as_archive to a brand new Rails 3.1 app and I get this error when running rake db:migrate :
AlsoMigrate error: undefined local variable or method `old_table' for AlsoMigrate::Migrator::InstanceMethods::AlsoMigrate:Module
It does not create any of the archiv tables.
I just use Rails 3.1 out of the box. ActsAsArchive was the first gem I added and tested.
We get this when trying to delete a model.
Seems like we will always have this problem. If the archive_* table contains the same columns, it will also include the id column. Thus if the where clause has id=X, it will be ambiguous.
I'm digging deeper into mover. https://github.com/winton/mover/blob/master/lib/mover.rb#L161
Could you please point me in the right direction?
Thanks!
> ud = UserDelegation.create!(:user => owner, :delegate => delegate) > ud.delete ActiveRecord::StatementInvalid: Mysql2::Error: Column 'id' in on clause is ambiguous: UPDATE archived_user_delegations AS t INNER JOIN user_delegations AS f ON f.id = t.id AND (`id` IN (4)) SET t.`custom_id` = f.`custom_id`, t.`email` = f.`email`, t.`invite_token` = f.`invite_token`, t.`deleted_at` = '2012-04-25 22:08:25', t.`user_id` = f.`user_id`, t.`created_at` = f.`created_at`, t.`first_name` = f.`first_name`, t.`last_name` = f.`last_name`, t.`id` = f.`id`, t.`updated_at` = f.`updated_at`, t.`delegate_id` = f.`delegate_id`
I am using rails 3.0.7 with a_a_a 0.4.1 and MySQL.
There are ":dependent => :destroy" annotations in my models.
When I run rake db:migrate new tables will be created with "deleted_at" fields, but no new class files are created. Also there are no new/renamed id fields for the altered dependencies. Shouldn't there be any?
Example:
Account model:
class Account < ActiveRecord::Base
has_many :invoices, :dependent => :destroy
config/acts_as_archive.yaml:
Account: - class: Account::Archive table: archived_accounts Invoice: - class: Invoice::Archive table: archived_invoices
I am getting the following error when trying to run migrate for the first time.
undefined method `devise' for #<Class:0x00000102d10f30>
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activerecord-3.1.0/lib/active_record/base.rb:1082:in `method_missing'
/Users/karl/workspace/viewthespace/app/models/user.rb:4:in `<class:User>'
/Users/karl/workspace/viewthespace/app/models/user.rb:1:in `<top (required)>'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:456:in `load'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:456:in `block in load_file'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:455:in `load_file'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:342:in `require_or_load'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:489:in `load_missing_constant'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:181:in `block in const_missing'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `each'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `const_missing'
I think this issue was already raised as issue #21, but for some reason github gives a 404.
I am using ruby 1.9.2 with rails 3.1.
thx!
rails (2.3.10)
acts_as_archive (0.3.2)
also_migrate (0.3.2)
Creating a sample project with acts_as_archive as a required gem caused migrations to fail with a "stack level too deep" error message.
To reproduce:
$ rails archive_test $ cd archive_test $ ruby script/generate migration user name:string $ rake db:migrate (works!)
Now add acts_as_archive as a required gem to config/environment.rb
$ rake db:drop $ rake db:migrate --trace (in projects/archive_test) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! stack level too deep /Library/Ruby/Gems/1.8/gems/also_migrate-0.3.2/lib/also_migrate/migrator.rb:29:in `migrate_without_also_migrate' /Library/Ruby/Gems/1.8/gems/also_migrate-0.3.2/lib/also_migrate/migrator.rb:29:in `migrate' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.10/lib/active_record/migration.rb:401:in `up' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.10/lib/active_record/migration.rb:383:in `migrate' /Library/Ruby/Gems/1.8/gems/rails-2.3.10/lib/tasks/databases.rake:112 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:in `load' /usr/bin/rake:19
It'd be great if the project could provide a Changelog. I've been digging through the commits, but I'm having a really hard time figuring out what actually changed from 0.2.5 -> 0.3.2. So, I'm not really sure if I should be upgrading or not.
I get the following error:
AlsoMigrate error: PGError: ERROR: syntax error at or near "LIKE"
LINE 2: LIKE emails;
^
: CREATE TABLE archived_emails
LIKE emails;
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:221:in log' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/postgresql_adapter.rb:520:in
execute'
Please tell me that i'm missing something idiotic and it works the way I expect it to.
It seems you have to either add acts as archived to every model associated with the record you want to archive or you have to call destroy_without_callbacks() on the object.
The first technique will only cause the associations that are :dependent=>destroy to also be destroyed in a way that's recoverable but it won't reverse the effects of before_/after_destroy callbacks. Since paperclip and most everything else use the callbacks to do their cleanup, attachments, for example, will be forever gone.
The second techique uses destroy_without_callbacks() instead of destroy(). This causes acts_as_archived to just use sql to move the record over to the archive table and bypasses all association dependent destroys and all cleanup by paperclip and like. That means that everything is still in place. ...and it's super quick! but, there is a downside. everything has to be carefully checked to make sure it's ready for a missing user_profile. Since conversations still show up in multiple places, you can still see lingering traces of this user_profile that doesn't technically exist.
The bigger killer with the later technique is that the destroy callbacks and association destroys don't get called when you destroy archived object :( I would have expected that if I find an object in the archive, that was deleted via destroy without callbacks, and then call destroy on the archived instance, it would then call all of the destroy callbacks and association :dependent=>:destroy.
Thanks for sharing this otherwise great piece of work,
~b
Hi all, I've got a question about this gem:
Supposing I have these models in Rails:
class Foo < ActiveRecord::Base
acts_as_archive ....
has_one :bar, :dependent => :destroy
end
class Bar < ActiveRecord::Base
acts_as_archive ...
belongs_to :foo
end
Then I do:
Foo.find(6).destroy # It ends up in Foo::Archive with id 6 and Foo.find(6).bar ends up in Bar::Archive
Then, much later, someone creates another Foo and unluckily it has id 6 and deletes it:
Foo.find(6).destroy # Primary key collision
What happens to the referential integrity of the archive tables?
We added acts_as_archive to a project using thinking_sphinx. When we did so,
thinking_sphinx lost the ability to determine the list of models that have sphinx indexes.
We're still trying to nail down if the issue is here or in thinking_sphinx, but I've got a hunch
acts_as_archive is making some change to the active record models it's added to which
break some conventions that thinking_sphinx is counting on.
When doing rake db:schema:load to init a new development database, the acts_as_archive gem was the source of a stack level too deep problem:
ethan-viziteis-imac-2:therapylogs ethan$ rake db:schema:load --trace
(in /Users/ethan/Documents/Rails/git/therapylogs)
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:schema:load
rake aborted!
stack level too deep
/Users/ethan/Documents/Rails/git/therapylogs/vendor/gems/acts_as_archive-0.2.4/lib/acts_as_archive/migration.rb:20:in method_missing_without_archive' /Users/ethan/Documents/Rails/git/therapylogs/vendor/gems/acts_as_archive-0.2.4/lib/acts_as_archive/migration.rb:20:in
method_missing'
/Users/ethan/Documents/Rails/git/therapylogs/db/schema.rb:14
/Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activerecord/lib/active_record/schema.rb:43:in instance_eval' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activerecord/lib/active_record/schema.rb:43:in
define'
/Users/ethan/Documents/Rails/git/therapylogs/db/schema.rb:12
/Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in load_without_new_constant_marking' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in
load'
/Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in
load'
/Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/railties/lib/tasks/databases.rake:269
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
execute'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:in
load'
/usr/bin/rake:19
ethan-viziteis-imac-2:therapylogs ethan$
Commenting out my requirement of the gem let me build my database, so there's a workaround, but just wanted to let you know.
Hello,
I was trying to find out why rake db:migrate wouldn't create any new tables even though I had the yaml config file specified correctly.
I found out you are trying to evaluate the model name (e.g. Article) in the load_from_yaml method during rails initialization and if something fails you rescue it with nil. The problem is you might have e.g. some acts_as_* statements in the affected model that hasn't been met yet. E.g. you utilize an acts_as_train plugin in the model but the plugin hasn't been loaded so in the "klass = eval(klass) rescue nil" statement you get an undefined method 'acts_as_train' error which results in nil.
If I install acts_as_archived as plugin and set the plugin load order to [:all, :acts_as_archived], it starts working.
Dependent associations that get archived aren't restored automatically.
Hello,
I m getting method_missing for 'devise' method error when i try to archive a class which belongs to another devise class. When i comment out the association line everything is ok. How can i fix this? Thanks..
Hi, I have an issue with loading server after I installed this gem with gem install acts_as_archive --include-dependencies
OS: Windows 7, x86
Ruby: 1.8.6
Gem: 1.3.6
Rails: 2.3.5
Here is a stack trace:
=> Booting WEBrick => Rails 2.3.5 application starting on http://0.0.0.0:3000 no such file to load -- lib/acts_as_archive/base C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:67:in `require' C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:67:in `require!' C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:62:in `each' C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:62:in `require!' C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:49:in `method_missing' C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:43:in `each' C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:43:in `method_missing' C:/ruby/lib/ruby/gems/1.8/gems/acts_as_archive-0.2.4/lib/acts_as_archive.rb:2 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:208:in `load' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `each' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:164:in `process' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run' C:/rails/todo/config/environment.rb:25 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:67:in `require': no such file to load -- lib/acts_as_archive (MissingSourceFile) from C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:67:in `require!' from C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:62:in `each' from C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:62:in `require!' from C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:49:in `method_missing' from C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:43:in `each' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' script/server:3 from C:/ruby/lib/ruby/gems/1.8/gems/require-0.2.1/lib/require.rb:43:in `method_missing' from C:/ruby/lib/ruby/gems/1.8/gems/acts_as_archive-0.2.4/rails/init.rb:2:in `evaluate_init_rb' from C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:158:in `evaluate_init_rb' ... 16 levels... from C:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84 from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from script/server:3
Tested on acts_as_archive >= 2.0.1, version 2.0.0 works fine.
As currently implemented, deployments thru Capistrano are much harder as you have to manually go into the production environment & run the command. If the command instead generated the migration, it could be deployed exactly the same as before thru cap deploy:migrations.
Hi-
I'm trying to get acts_as_archive with Rails 3.0.0 and Ruby 1.9.2. When I use gem 'acts_as_archive'
in the Gemfile, and add the acts_as_archive
line in my model, I get this error when trying to query the archive (I ran rake db:migrate
but it didn't look like any migrations were run):
ruby-1.9.2-p0 > Shareable::Archive.first
NameError: undefined local variable or method `acts_as_archive' for #<Class:0x0000010451ce58>
Also tried to install the Gem from Github with gem 'acts_as_archive', :git => 'git://github.com/winton/acts_as_archive.git'
and got this error:
`/Users/xxx/.rvm/gems/ruby-1.9.2-p0@rails3/bundler/gems/acts_as_archive-fab88766f555/lib/acts_as_archive/gems.rb:118:in `dependency_filter': undefined method `inject' for "nil":String (NoMethodError)`
I'm probably missing something simple here, but can't quite figure it out. Any help would definitely be appreciated.
Thanks.
Hi,
I've noticed indexes for "polymorphic" columns are failing :
acts_as_archive :indexes => [ user_id, [:model_id, :model_type]]
I should have an index on user_id and model_id+model_type, instead I get an error :
ActiveRecord::StatementInvalid: PGError: ERROR: column "model_idmodel_type" does not exist
Hi,
I have created the config file but after running migration, no archive table is created. I am using Rails 3.2 and ruby 1.9 and latest version of acts_as_archive. Based on some previous issues, I also added acts_as_archive to my original table but that also didn't help. Am I missing any critical step ?
Ritesh
Hi, I'm trying to restore a record following the documentation:
Property::Archive.last.destroy
But it isn't restored, so I'm checking the source of the plugin and debugging and I can see this:
(rdb:1) p merge_options
{}
(rdb:1) p where
"`id` = 28786"
(rdb:1) p config[:to]
Property::Archive(...)
...
(rdb:1) p config[:from]
Property(...)
So I don't know why it is moving the record to the archive table instead of the other table.
I'm using Rails 3.1 and just put acts_as_archive into my gemfile. Doing nothing else, I ran rake and get the following dump: It looks as though there is some invalid yaml in the gem. If I change my yaml parser to syck, it's ok (but syck is an old parser and should not be used).
rake --trace
rake aborted!
couldn't parse YAML at line 2 column 9
/blah/blah/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in parse' /blah/blah/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in
parse_stream'
/blah/blah/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:119:in parse' /blah/blah/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:106:in
load'
/blah/blah/ruby-1.9.2-p290@rails3/gems/acts_as_archive-0.4.0/lib/acts_as_archive/gems.rb:66:in block in gemset=' /blah/blah/ruby-1.9.2-p290@rails3/gems/acts_as_archive-0.4.0/lib/acts_as_archive/gems.rb:64:in
collect'
/blah/blah/ruby-1.9.2-p290@rails3/gems/acts_as_archive-0.4.0/lib/acts_as_archive/gems.rb:64:in gemset=' /blah/blah/ruby-1.9.2-p290@rails3/gems/acts_as_archive-0.4.0/lib/acts_as_archive/gems.rb:37:in
activate'
/blah/blah/ruby-1.9.2-p290@rails3/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:3:in <top (required)>' /blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in
require'
/blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in block (2 levels) in require' /blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in
each'
/blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in block in require' /blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in
each'
/blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in require' /blah/blah/ruby-1.9.2-p290@rails3/gems/bundler-1.0.18/lib/bundler.rb:120:in
require'
This is a repeat of issue #21 i think, but whenever i click on that issue, i get a 404 from github. I am using rails 3.1 with ruby-1.9.2 with devise 1.4.5.
undefined method `devise' for #<Class:0x00000102d10f30>
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activerecord-3.1.0/lib/active_record/base.rb:1082:in `method_missing'
/Users/karl/workspace/viewthespace/app/models/user.rb:4:in `<class:User>'
/Users/karl/workspace/viewthespace/app/models/user.rb:1:in `<top (required)>'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:456:in `load'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:456:in `block in load_file'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:455:in `load_file'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:342:in `require_or_load'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:489:in `load_missing_constant'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:181:in `block in const_missing'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `each'
/Users/karl/.rvm/gems/ruby-1.9.2-p290@viewthespace/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `const_missing'
class Comment < ActiveRecord::Base
belongs_to :item, :polymorphic => true
end
when i run db:migrate -t
it gives
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant Comment::Item
/home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.5/lib/active_record/base.rb:1199:in compute_type' /home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.5/lib/active_record/reflection.rb:162:in
klass'
/home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:130:in block in acts_as_archive' /home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:129:in
each'
/home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:129:in acts_as_archive' /home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:56:in
block (2 levels) in load_from_yaml'
/home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:55:in each' /home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:55:in
block in load_from_yaml'
/home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:47:in each' /home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:47:in
load_from_yaml'
/home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/acts_as_archive-0.4.0/lib/acts_as_archive/adapters/rails3.rb:4:in block in <class:ActsAsArchiveRailtie>' /home/ayaya/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:25:in
instance_exec'
Hi,
I'm seeing this issue both in our app as well as in the acts_as_archive test suite after porting it to work with Rails 3.1. The delete_sql alias is never being called as far as I can tell. I don't know if Rails is using a new codepath or something else is afoot. The method is being included correctly into the adapter, but is not being called when a record is destroyed, so nothing is archived.
even with suggested modifications in code for running 3.1
fine for db:migrate, but cannot do db:rollback correctly..
not running fine with migrations in development mode:
when doing a rake db:rollback
yves$ rake db:rollback
== CreateAreaServicesTable: reverting ========================================
-- drop_table(:area_services)
-> 0.0021s
== CreateAreaServicesTable: reverted (0.0022s) ===============================
rake aborted!
An error has occurred, all later migrations canceled:
wrong number of arguments (1 for 3)
TRACE--------
/Users/yves/.rvm/gems/ruby-1.9.3-p0@rails32/bundler/gems/acts_as_archive-0ec158dd1ca8/lib/acts_as_archive.rb:206:in delete_with_archive' /Users/yves/.rvm/gems/ruby-1.9.3-p0@rails32/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in
delete'
/Users/yves/.rvm/gems/ruby-1.9.3-p0@rails32/gems/activerecord-3.2.0/lib/active_record/migration.rb:740:in record_version_state_after_migrating' /Users/yves/.rvm/gems/ruby-1.9.3-p0@rails32/gems/activerecord-3.2.0/lib/active_record/migration.rb:705:in
block (2 levels) in migrate'
END TRACE -----
I tried to disable it in the development environment
ActsAsArchive.disabled = true
but now way ...
Okay, I'm probably doing something stupid...
I'm using Ruby 1.9.2, Rails 3.0.3 and acts_as_archive 0.4. I already posted in the "Hi there" thread about the yml file not working, but once I put 'acts_as_archive' in my model it worked fine.
That's still the case - in development mode. When I did that my archive table was created.
However, when I run db:migrate RAILS_ENV=production the archive table doesn't get created in my production database. Any ideas?
Thanks,
Larry
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.