Giter Site home page Giter Site logo

acts_as_versioned's People

Contributors

asacalow avatar bridiver avatar codez avatar foobarwidget avatar gvarela avatar josh avatar maiha avatar metaskills avatar ngocdaothanh avatar pelle avatar technoweenie avatar thibaudgg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

acts_as_versioned's Issues

Getting the active version

there can be multiple version that requires approval. how do i set the versions to show only the approved version. Versions can be approved by admin

MySQL decimal Datatype Requires Migration With ":precision => ..." to Avoid "No integer type has byte size " Error

Steps to reproduce:
Create a new Rails app with a single model named "bill.rb" with acts_as_versioned .
Set config/database.yml to use MySQL
Generate a migration called "create_bills".
In this migration, create a table named "bill" with a single attribute named "amount" with a "decimal" datatype. Include the "Bill.create_versioned_table" line.
Try "rake db:migrate" (db:drop & db:create as needed).
Note: No integer type has byte size 10 rake aborted! error
Add a specification of :scale => 2 to the migration datatype specification. The error remains.
Add a specification of :precision => 8 (even without :scale). The error disappears.

Tested on OSX 10.5.8, Ruby 1.8.6, Rails 2.3.3, acts_as_versioned 0.2.3

undefined method `table_exists?' for #

can t figure it out, need some help

undefined method table_exists?' for #<ActiveRecord::ConnectionAdapters::MysqlAdapter:0x48ac664> D:/WebApp/payr/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb:412:increate_versioned_table'

rails 1.2.3
ps. I m trying to run the example application of ruport - payr, too many places to fix!

Support for Rails 3.0.1

Error in a Rails 3.0.1 project:

Bundler could not find compatible versions for gem "activerecord": In Gemfile: rails (= 3.0.1) depends on activerecord (= 3.0.1) acts_as_versioned depends on activerecord (3.0.0) (Bundler::VersionConflict)

missing gem

despite the fact that gem option is switched on at this repo, gem technoweenie-acts_as_versioned cannot be found :(

First save ignores :if condition

When saving a versioned model for the first time, a version is created regardless of the :if condition.

E.g. if I do

acts_as_versioned :if => Proc.new {|item| false}

I will still get a new record in the _versions table when calling the first save() (or create()) on my model.

I suppose there's a reason for this, but from my point of view when the :if condition is false no version should be saved, ever.

I think the behavior stems from line 391 in acts_as_versioned.rb.

@saving_version = new_record? || save_version?

Why do new records get to bypass the version saving conditions?

Something wonky about the cloned extension

SomeModel.versions.first.some_association.anything doesn't work, even though the association itself is found just fine.

I'm not sure how to fix this; it presumably has something to do with inheritance chaining...

Example 1:

>> User.find(Profile.last.versions.last.user_id)
=> #<User id: 1, login: "saizai", ...
>> Profile.last.user
=> #<User id: 1,
>> Profile.last.versions.last.user
NoMethodError: undefined method `user' for #<Profile::Version:0x25fdc30>
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in `method_missing'

Example 2:

>> Profile.last.versions.last.updater
=> #<User id: 1, login: "saizai", ...
>> Profile.last.versions.last.updater.name
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods'
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `each'
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods'
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:351:in `respond_to?'
from /Users/saizai/Dropbox/workspace/hyperdictionary/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:213:in `method_missing'
from (irb):99
from :0
>> User.find(Profile.last.versions.last.updater_id)
=> #<User id: 1, login: "saizai", ...
>> User.find(Profile.last.versions.last.updater_id).name
=> "Rootage"
>> Profile.last.versions.last
=> #<Profile::Version id: 2, ...
>> Profile.last.versions.last.skip_time_zone_conversion_for_attributes
=> []
>> Profile.last.versions.last.updater.skip_time_zone_conversion_for_attributes
=> nil
>> User.find(Profile.last.versions.last.updater_id).skip_time_zone_conversion_for_attributes
=> []

Getting the active version

there can be multiple version that requires approval. how do i set the versions to show only the approved version. Versions can be approved by admin of a moderator has to approve all versions

Missing columns in _versions table cause error

acts_as_versioned should determine which columns to version, based on the #{model}_versions table.

The documentation for ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned says:

The _versions table should contain all the fields you want versioned

but this is clearly not the case (with version 0.5.2). For any attributes missing in the _versions table, I get:

undefined method attribute=' for #Model::Version:0x180dfe4 vendor/acts_as_versioned/lib/acts_as_versioned.rb:331:in send'
vendor/acts_as_versioned/lib/acts_as_versioned.rb:331:in clone_versioned_model' vendor/acts_as_versioned/lib/acts_as_versioned.rb:330:in each'
vendor/acts_as_versioned/lib/acts_as_versioned.rb:330:in clone_versioned_model' vendor/acts_as_versioned/lib/acts_as_versioned.rb:273:in save_version'

MySQL/PosgreSQL: Index name on table is too long; the limit is 63 characters

Rails >= 3.0.3 aborts migrations if they try to create an index with a name are longer than 64 characters on PostgreSQL or MySQL (yes, 64, not 63 like the error says).

When acts_as_versioned creates indexes, it does not check the length of the resulting index name.

The patch below fixes that. It fixes the problem on MySQL and PostgreSQL (I tested both).

--- acts_as_versioned.rb    2011-05-06 11:37:30.000000000 -0400
+++ acts_as_versioned.rb    2011-05-06 11:29:47.000000000 -0400
@@ -440,7 +440,9 @@
                                          :precision => type_col.precision
             end
 
-            self.connection.add_index versioned_table_name, versioned_foreign_key
+            # Make sure not to create an index that is too long (postgres limits index names to 64 characters)
+            name = 'index_' + versioned_table_name + '_on_' + versioned_foreign_key
+            self.connection.add_index versioned_table_name, versioned_foreign_key, :name => name[0,63]
           end
 
           # Rake migration task to drop the versioned table

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.