-
-
Notifications
You must be signed in to change notification settings - Fork 229
Cannot define multiple 'included' blocks for a Concern #111
Comments
I just got the same error with my app. Also Rails 4.2.0 and Ruby 2.2.0. ActiveSupport::Concern::MultipleIncludedBlocks - Cannot define multiple 'included' blocks for a Concern: |
Try my fork: https://github.com/safetypins/vestal_versions I resolved all of the errors I ran into and it appears to be working as expected. The only thing that doesn't work as advertised originally is the user attribution. It looks like it's just not possible to associate the user passing the updated_by attribute to update_attributes(). However, I was able to set the updated_by property prior to the update_attributes() call and it attributed changes as expected. This was suggested somewhere else on the internets, and I just added the instructions to the README so it was clear. I haven't tested everything. Frankly I'm uncertain of how to test a module, I'm not familiar with rspec, I'm very busy with other things, and it's working for me, so I'm not very motivated to figure it out. I also don't have time to figure out how to turn this thing into a proper gem that can be installed via gem install, but I think the gem is worth it. It seems like a really good implementation of versioning. I think the only thing I don't like is the duplication of content: each revision contains the previous and new values. If you're versioning a long text field, this could get really bulky over time. I don't understand why the values need to be stored from and two, especially since the model tracks a self-referential "reverted_from" column. Maybe to reduce database interaction? Anyway, I was originally thinking it would be nice to integrate the functionality of differ or diffy but it would probably be better to just use both gems to implement the revision UI the way I want.. |
AWESOME! I totally get what you're saying about being too busy with important stuff to be able to test/fully get the gem in working condition, i'm too busy as well...as far as I'm concerned though it's working now and I really appreciate it. If I run into any issues or whatnot I'll try and figure it out. How are you setting the updated_by prior to update_attributes? |
Here's my code: https://gist.github.com/safetypins/e719c3ebc2b0a3de317e The attr_accessor property of updated_by is set in the vestal_versions module (I think), so I'm pretty sure all you have to do is assign a value (you can use a name or an instance) and then update_attributes. Keep in mind, if no attributes are changed, then there won't be a new version created. |
Don't know if you've ran into this problem or if it's just on my app but I cannot delete models that are versioned. |
I haven't. The models that I'm versioning in the app are not designed to be deleted, so I haven't tried to delete any of them. So, there's this thing that they got rid of in modules, can't remember exactly, but if you look through the commits, you'll see that I performed the same operation in several of the files. It's basically a block that they removed, something about instance methods, I think? in several places I was getting an undefined method error, and when I looked, I saw the the function was defined, but it was inside this block, and if I moved it outside the block, then it worked correctly. I don't fully understand it. |
@R1V3R5 I can confirm that I'm getting the same error when I try to destroy an instance. We are now looking into migrating away from vestal_versions to paper_trail. |
See laserlemon#111. This issue seems to be the gem defines 2 Version::VersionMethods modules, one users.rb and one in version_tagging.rb, each with an `included` block. As quick proof of concept rename the module in VersionTagging (since we don't use that feature) to `VersionTaggingMethods` and update the `class_eval` block to reflect the change. A better approach might be to namesoace each `VersionMethods` module to the parent module, e.g. `VestalVersions::VersionTagging::VersionMethods` and `VestalVersions::User::VersionMethods`
I'm attempting to use vestal_versions with a Rails 4.2 app, and Ruby 2.2, But after adding the gem, running the migration, and adding the 'versioned' method to the models I want to be versioned, I get the following error. Is there a rails 4/ruby 2.2 compatible fork of vestal_versions out there?
Extracted source (around line #126):
124 def included(base = nil, &block)
125 if base.nil?
126 raise MultipleIncludedBlocks if instance_variable_defined?(:@_included_block)
127
128 @_included_block = blockvendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/concern.rb:126:in 'included'
vendor/bundle/ruby/2.1.0/bundler/gems/vestal_versions-beccc5744ec0/lib/vestal_versions/version_tagging.rb:29:in '<module:VersionMethods>'
vendor/bundle/ruby/2.1.0/bundler/gems/vestal_versions-beccc5744ec0/lib/vestal_versions/version_tagging.rb:26:in '<module:VestalVersions>'
The text was updated successfully, but these errors were encountered: