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

More helpful error message when instantiating an abstract class #9474

Merged
merged 1 commit into from Mar 7, 2013

Conversation

Projects
None yet
4 participants
@HonoreDB
Contributor

HonoreDB commented Feb 27, 2013

Calling a literal ActiveRecord::Base.new raises NoMethodError,
since it ends up calling Class.abstract_class? which does not exist.
Similarly, instantiating an actual abstract class hits the database,
when conventionally it should immediately throw NotImplementedError.

ActiveRecord::Base can't be made abstract without breaking many,
many things, so check for it separately.

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Feb 28, 2013

Member

can you write two test cases to verify that AR::Base cant be instantiated and that an abstract class can't be instantiated?

Also we would need a CHANGELOG entry explaining the change.

Member

senny commented Feb 28, 2013

can you write two test cases to verify that AR::Base cant be instantiated and that an abstract class can't be instantiated?

Also we would need a CHANGELOG entry explaining the change.

@schneems

This comment has been minimized.

Show comment
Hide comment
@schneems

schneems Mar 3, 2013

Member

@HonoreDB comment-ors don't get notified when you push, you have to reply to the thread for them to know. @senny care to take a second look?

Member

schneems commented Mar 3, 2013

@HonoreDB comment-ors don't get notified when you push, you have to reply to the thread for them to know. @senny care to take a second look?

@senny

View changes

Show outdated Hide outdated activerecord/CHANGELOG.md
@senny

View changes

Show outdated Hide outdated activerecord/lib/active_record/inheritance.rb
@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Mar 3, 2013

Member

added a few minor comments.

Member

senny commented Mar 3, 2013

added a few minor comments.

@HonoreDB

This comment has been minimized.

Show comment
Hide comment
@HonoreDB

HonoreDB Mar 3, 2013

Contributor

Thanks, comments addressed in HonoreDB@f128e79.

Contributor

HonoreDB commented Mar 3, 2013

Thanks, comments addressed in HonoreDB@f128e79.

@senny

View changes

Show outdated Hide outdated activerecord/test/cases/base_test.rb
@senny

View changes

Show outdated Hide outdated activerecord/test/cases/base_test.rb
@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Mar 3, 2013

Member

the PR does no longer cleanly apply to master. Can you push a rebased version?

Member

senny commented Mar 3, 2013

the PR does no longer cleanly apply to master. Can you push a rebased version?

More helpful error message when instantiating an abstract class
Calling a literal ActiveRecord::Base.new raises NoMethodError,
since it ends up calling Class.abstract_class? which does not exist.
Similarly, instantiating an actual abstract class hits the database,
when conventionally it should immediately throw NotImplementedError.

ActiveRecord::Base can't be made abstract without breaking many,
many things, so check for it separately.
@HonoreDB

This comment has been minimized.

Show comment
Hide comment
@HonoreDB

HonoreDB Mar 3, 2013

Contributor

Rebased, tests now check the error message in addition to the type.

Contributor

HonoreDB commented Mar 3, 2013

Rebased, tests now check the error message in addition to the type.

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Mar 3, 2013

Member

@HonoreDB amazing! thanks for the fast update. 💛

@carlosantoniodasilva @rafaelfranca can you take a final look?

Member

senny commented Mar 3, 2013

@HonoreDB amazing! thanks for the fast update. 💛

@carlosantoniodasilva @rafaelfranca can you take a final look?

rafaelfranca added a commit that referenced this pull request Mar 7, 2013

Merge pull request #9474 from HonoreDB/master
More helpful error message when instantiating an abstract class

Conflicts:
	activerecord/CHANGELOG.md

@rafaelfranca rafaelfranca merged commit 53f18f2 into rails:master Mar 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment