-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails3 support #30
Rails3 support #30
Conversation
This fixes the Rails3 exception: ActiveRecord::DangerousAttributeError: changes is defined by ActiveRecord
Please update. |
Hi Dmitry, Please clarify what you'd like me to update. I should point out that this patch only fixes acts_as_audited when it was installed on a Rails 2.x app. That is, I created a rails 2.x app, installed acts_as_audited and generated the migration, then upgraded to rails 3 and applied this patch. Creating a new rails 3 app and trying to run the acts_as_audited generator still breaks. -Aaron |
Hi Aaron, I think update of migration generator to a new rails isn't a real problem. What I really care is that the owner of this gem updated it with the rails 3 support. If it's only possible with a new migration generator (for rails 3), I can write patch and include it here. Thank you. |
Thanks Aaron I think I'll branch of your work and clean the entire gem up so we can release a new major version that supports Rails 3 in all it's shining glory. This will take some work from my side, getting the test suite up to date and making the gem a Railtie... Best |
Hey guys I've just pushed a huge bunch of changes to the 'rails3' branch for review. This would ultimately become acts_as_audited 2.0.0 once I get the thumbs up from everyone. Please checkout the code locally, run 'bundle install', build the gem & install it and test it on a shiny new Rails 3 project. Best |
So I've successfully installed the rails3 branch in my rails3 project and I'm auditing a few models but for all my audits there are no values in action or changes. Audit.last.changes => {} |
x37v: Audit#changes was renamed to Audit#audited_changes. ActiveRecord::Base now defines a "changes" method that returns a hash of changes attributes on that object. So we renamed "changes" to avoid collision. |
Ahh, I figured out my problem. |
x37v: I ran into an error with checking for nil, checking empty? was better. Unless my app has something else funny, accessible_attributes should not be nil, but rather empty. ruby-1.9.2-p0 > Email.accessible_attributes => #<ActiveModel::MassAssignmentSecurity::WhiteList: {}> ruby-1.9.2-p0 > Email.accessible_attributes.nil? => false ruby-1.9.2-p0 > Email.accessible_attributes.empty? => true ruby-1.9.2-p0 > Email.accessible_attributes.count => 0 See another issue I posted, as well as a pull request |
I was able to use the 2.x version but when I tried to install the 3.x version (2.0.0 rcl) on a brand new rails 3 project it failed with |
I have the same issue as durrantm. I don't see any "2.0.0.rc1" tag in the Switch Tags list either. Same for rc2. |
I think I got around it by using rc2 instead of rc1 ... but in any case, I had to fork to fix a bug, and no one has responded to my pull requests yet. |
I used the acts_as_audited_rails3 gem for the time being. |
Hi guys Sorry for delays on posting here. @dgm, your pull request is in along with others. In general, use the following in your Gemfile until I get permissions to push to Rubygems gem "acts_as_audited", "2.0.0.rc3", :git => "git://github.com/collectiveidea/acts_as_audited.git", :tag => "2.0.0.rc3" Just keep track off the tags as I work towards a 2.0.0 stable. |
Thank you kenneth. |
Looks great. I managed to install acts_as_audited 2.0.0.rc3 on rails3 sample app. Changes to the model are recorded, but the audited_changes column stays empty. Do I have to change something more? |
@zettworks, no, can you check against 2.0.0.rc4 (now on rubygems) and open a bug with some re-produceable steps that I can follow (if needed) ? |
Kenneth, you may already may know this, but I did some investigation, and changing the use of the deprecated 'reorder' method by Audit to use 'except(:order).order(...)' cannot happen until Rails 3 because of this bug https://rails.lighthouseapp.com/projects/8994/tickets/6011-exceptorderorder-is-not-working-in-scopes |
Yep, very well aware of that. Watching that ticket until I find a cleaner solution (or it gets fixed). It is more important for me to get the Railtie in, and release. I can always do a point release once we've figured out a way around it. |
Hey there,
Thanks for making acts_as_audited. It's a great plugin.
I got it working in my rails3 app with these two changes:
Renaming the audits.changes column might be a hassle for legacy users, but it worked for me b/c I'm starting from scratch. If you know of a better way of circumventing the DangerousAttributeError, go for it!
Cheers,
Aaron