Skip to content
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

Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raised #17541

Merged
merged 1 commit into from
Nov 7, 2014

Conversation

frankywahl
Copy link
Contributor

Currently, there is no messages which get printed out. Convoluted system
may have hooks that create other objects in which case we only fail with
no messages. This commit changes this information allowing you to know
which object is the one that actually raised the error.

@rafaelfranca
Copy link
Member

Could you show a example of the generated message?

@frankywahl
Copy link
Contributor Author

I've created an example here: https://github.com/frankywahl/rails_examples

If you run rake example you will see the error I'm speaking about due to https://github.com/frankywahl/rails_examples/blob/master/app/models/foo.rb#L3-L5

But as you will see, the error is not descriptive of which model failed, you only see:

rake aborted!
ActiveRecord::ReadOnlyRecord: ActiveRecord::ReadOnlyRecord
<PATH_TO_PROJECT>/lib/tasks/example.rake:3:in `block in <top (required)>'
Tasks: TOP => example
(See full trace by running task with --trace)

With my change, you would see:

rake aborted!
ActiveRecord::ReadOnlyRecord: Foo is marked as readonly
<PATH_TO_PROJECT>/lib/tasks/example.rake:3:in `block in <top (required)>'
Tasks: TOP => example
(See full trace by running task with --trace)

@sgrif
Copy link
Contributor

sgrif commented Nov 6, 2014

This needs a test.

@frankywahl frankywahl force-pushed the meaninful_message branch 5 times, most recently from 219480e to 3c8b4e8 Compare November 7, 2014 03:27
Currently, there is no messages which get printed out. Convoluted system
may have hooks that create other objects in which case we only fail with
no messages. This commit changes this information allowing you to know
which object is the one that actually raised the error.
@senny senny merged commit d424ded into rails:master Nov 7, 2014
senny added a commit that referenced this pull request Nov 7, 2014
Print out a meaningful error when ActiveRecord::ReadOnlyRecord is raised
@senny
Copy link
Member

senny commented Nov 7, 2014

@frankywahl thank you 💛

@frankywahl frankywahl deleted the meaninful_message branch November 7, 2014 16:13
@frankywahl
Copy link
Contributor Author

@senny My Pleasure ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants