This project is archived and is in readonly mode.
Confusing behavior with attr_readonly
-
Trevor Turk
I've updated this patch to be less intrusive in terms of changing the remove_readonly_attributes method. I also changed the ReadOnlyAttributeError so that it descends from ActiveRecordError instead of NoMethodError.
I left in the readonly_attributes_include? class method and improved its testing. Perhaps there's a better approach to this, though. Maybe it should be made private? Maybe we don't need it?
Lastly, I realized that ReadOnlyAttributeError probably wouldn't be raised when attempting to update a nested attribute. I didn't test this, and I'm not sure we need to worry about for now, but I'm happy to check into it if we think it's worthwhile.
Thanks!
-
Mike Breen
- Tag changed from activerecord, patch to activerecord, bugmash, patch
verified that the patch applies cleanly to 2-3-stable
-
Elad Meidar
+1 Verified, i got my hands wrapped with this bug for a long time...
Patch failed on master so i attach a clean one.
-
Elad Meidar
Arg.
here's the patch
-
Mike Breen
+1 verified Elad's patch applies cleanly to master. all tests are green
-
dira
+1 - this behavior is a lot less confusing as the previous one
I attached a patch. The previous patch did not apply on master anymore; the attached one does.
-
Elomar França
+1 for the feature, but the patches does not seem to work on SQLite3:
/test/cases/base_test.rb:937:in
test_update_attribute_raises_an_exception_if_given_a_readonly_attribute'test_update_attribute_raises_an_exception_if_given_a_readonly_attribute(BasicsTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: posts.body may not be NULL: INSERT INTO "posts" ("title", "body", "taggings_count", "type", "author_id", "comments_count") VALUES('cannot change this', NULL, 0, 'ReadonlyTitlePost', NULL, 0)Tested in 1.8.7, 1.8.6 and 1.9.1
-
Matías Flores
+1 for the feature, it's less confusing than the current behavior
-
Santiago Pastorino
- State changed from new to open
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
-
Michael
I came across this same confusing behavior and eventually ended up here.
I'm getting an error when trying to view the attached patch:
"NoSuchKeyThe specified key does not exist"Can anyone re-attach?
M
