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
Rails 4.2 still complains about deprecated ActiveRecord #column_for_attribute #3838
Comments
Ok, since the PR has been closed, can we review what to actually do here? The commit history I outlined here shows that the aa team seems to have considered and rejected actually taking action to remove the deprecated action. While I agree that silencing deprecation warnings is a bad idea in general, I think that as a library — integrated by many other orgs into their rails apps — ignoring the deprecation warnings is even worse. It will waste tons people's future time since each and every org that uses active admin will have to separately investigate the deprecation warning, deal with their own internal policies about deprecation warnings, etc. So if we could revisit the previous commits here, can we agree that it would be preferable to have a fix that works correctly and does not emit the deprecation warning? @gonzedge - you contributed 48ccc3d — I have read the commit message, but I don't completely follow it. Possibly multiple rails versions are involved here, but you didn't specify. Also, I get tons of failures on my MacBook running 10.10.2 when I try to run the test suite. I see Travis says the build is good? I looked at the contribution guidelines and it doesn't make it sound like running the tests is that hard; should I be able to get them working on my machine or do they only run on Linux or some other caveat I didn't see? I'd love to make a fix that works and doesn't emit the warning, but I wouldn't make substantive changes to a project whose test suite I can't run. |
Oh, yeah, pull in @timoschilling since he closed the PR. Really would like to figure out something positive to do here rather than just ignoring the problem. |
@rdj what sort of test failures are you getting locally? Perhaps we could jump on IRC to try and figure what's happening together. |
@rdj I agree with you too. Ignoring is not a solution. Hope you find a better way |
@seanlinsley Thanks, here's what I'm currently seeing.
I start with a completely blank slate in an isolated empty rvm gemset. I run I run Seems like the Ok, so poking around I see that I can drop a .rails-version file to control what rails version I'm using, plus there's a script/use_rails for hotswitching between. So I decide I'll try rails 4.2.1.rc3 since that's what I'm trying to work fix problems with. I'll clean everything back out first though.
Here's the Gemfile.lock for that: https://gist.github.com/rdj/786a8667a523088c0f2e Then when I run |
Double checked everything and get the same results. I also tried Rails 4.2 just for completeness and got a different type of failure: https://gist.github.com/rdj/5e7ee9c5b88f3a0197eb |
Spun up a clean Ubuntu Trusty machine on EC2 and I get the same results, so I guess at least it's not Mac specific. (Though on linux I had to manually add therubyracer to the Gemfile.) |
@rdj any updates? |
@timoschilling I was never able to get tests running, so I'm in no position to prepare a fix. In my app, these deprecations were coming up where an auto-formatted column ( I see now that the IRC channel is specified in the README.md, which I had missed at the time. I'm working on a different project at the moment, but perhaps I will have some time in the next couple of weeks to pop in. Like I said, I'd be happy to investigate if I can get the tests running. |
@timoschilling , why we need Why not to check if value is boolean and not to check column type and so on? something like
What do you think? |
What's about nil? |
@timoschilling, I'm looking at tests and looks like it was decided to render nil as "No" for boolean columns , is that true ? Can we change this or no ? |
@Fivell yes, It wasn't well documented on the original Rails pull request, but in our case we should update our code to use |
Wait, this was already done in #3487, but then it later got reverted by #3730? The reasoning for that change was:
They didn't go into detail how exactly the |
CC @gonzedge |
@seanlinsley, let me describe "problematic" example.
calling #column_for_attribute will be always nil , which will give deprecation warning for rails 4.2.However they can be still boolean , thats why I though checking value can help |
@gonzedge, can you tell what exact tests are failing? |
I'm taking a look at the commit right before my pull request. I'll be back soon with the test failures. |
Below are my results on ruby The commit 38bf023 was right before my pull request (#3730). git checkout 38bf023 Once you checkout that commit, you'll have to change the gem 'inherited_resources', github: 'josevalim/inherited_resources', ref: '9f1c0edd6b4c' Then, bundle and test (which will fail in the unit tests): rm Gemfile.lock # it's possible that this part isn't such a great idea
RAILS=4.2.0 bundle
RAILS=4.2.0 bundle exec rake test These are the unit test failures I'm getting. The important ones here are 1 and 5 on
From
Notice the For After updating to commit e7dafc5, I don't get the highlighted failures anymore ( |
Running the tests with ruby |
@seanlinsley , I'm still voting for detecting is_boolean by value not by db columns, we can change rendering nil values as grey status tag with "NULL"/"NONE"/"EMPTY". This will give us next
none of this will work if you will rely on active-record column , also if we are talking about #3930 , there can be problems with decorated collection, As I know class methods are not available for such records |
I don't agree, @Fivell. We can detect whether the column is boolean, and we have done so historically, therefore we should continue to. That's not to say that we can't also automatically use |
@seanlinsley, maybe at least we can use |
Yes, that's what I'm suggesting we do. |
Forgive me for digging up an old issue, but was this ever actually resolved? I'm trying to clean up deprecation warnings in my app, and I'm using the latest version of AA (1.0.0.pre2), and I still see this warning. If it was resolved, can someone point me to the commit that resolved it? Edit: found it: 3b1737b So, how close are we to another version bump? |
@dkniffin the problem is that there are a lot of breaking changes in master that aren't document in the changelog. Once I find the time to update the changelog, I'll release 1.0.0 proper. |
Active Admin produces a deprecation warning with Rails 4.2.1.rc3:
DEPRECATION WARNING:
#column_for_attributewill return a null object for non-existent columns in Rails 5. Use
#has_attribute?if you need to check for an attribute's existence. (called from is_boolean? at /var/jenkins/.rvm/gems/ruby-2.2.1@project/bundler/gems/active_admin-96c6db140e57/lib/active_admin/views/components/table_for.rb:120)
This was previously reported in #3487 (fixed c8e54d2) and then amended in a way that reintroduced the deprecation warning (48ccc3d).
That last commit provides justification for a why the method should be used. The problem remains, however, that anybody using Active Admin will deal with the noise of the deprecation warning.
Rails provides a way to silence deprecation warnings on a particular section of code when you've decided you know better. Now is the time to use it.
The text was updated successfully, but these errors were encountered: