rm cached attributes #15429

Merged
merged 1 commit into from Jun 11, 2014

Conversation

Projects
None yet
4 participants
@sgrif
Member

sgrif commented May 30, 2014

The original patch that added this concept can be found here. The current default behavior is to cache everything except serialized columns, unless the user specified otherwise. If anyone were to specify otherwise, many types would actually be completely broken. Still, the method is left in place with a deprecation warning in case anyone is actually still calling this method.

-
- # Returns the attributes which are cached. By default time related columns
- # with datatype <tt>:datetime, :time, :date</tt> are cached.
- def cached_attributes

This comment has been minimized.

@rafaelfranca

rafaelfranca May 30, 2014

Member

We need to deprecate this one too.

@rafaelfranca

rafaelfranca May 30, 2014

Member

We need to deprecate this one too.

- end
-
- # Returns +true+ if the provided attribute is being cached.
- def cache_attribute?(attr_name)

This comment has been minimized.

@rafaelfranca

rafaelfranca May 30, 2014

Member

And this one

@rafaelfranca

rafaelfranca May 30, 2014

Member

And this one

This comment has been minimized.

@sgrif

sgrif May 30, 2014

Member

Updated

@sgrif

sgrif May 30, 2014

Member

Updated

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
Member

rafaelfranca commented May 30, 2014

@jeremy WDYT?

@sgrif

This comment has been minimized.

Show comment
Hide comment
@sgrif

sgrif May 30, 2014

Member

Note: This does not change behavior for anyone who has not called cache_attributes on a model.

Member

sgrif commented May 30, 2014

Note: This does not change behavior for anyone who has not called cache_attributes on a model.

@sgrif

This comment has been minimized.

Show comment
Hide comment
@sgrif

sgrif Jun 6, 2014

Member

@jeremy Ping!

Member

sgrif commented Jun 6, 2014

@jeremy Ping!

@sgrif

This comment has been minimized.

Show comment
Hide comment
@sgrif

sgrif Jun 7, 2014

Member

@rafaelfranca @jeremy Any more feedback on this? Need this for what I'm working on.

Member

sgrif commented Jun 7, 2014

@rafaelfranca @jeremy Any more feedback on this? Need this for what I'm working on.

@sgrif

This comment has been minimized.

Show comment
Hide comment
Member

sgrif commented Jun 9, 2014

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jun 9, 2014

Member

For me it is :shipit: but maybe @jeremy is using it for something or he knows some use case that we are not aware of. I'll try to get him reviewing it.

Member

rafaelfranca commented Jun 9, 2014

For me it is :shipit: but maybe @jeremy is using it for something or he knows some use case that we are not aware of. I'll try to get him reviewing it.

@sgrif

This comment has been minimized.

Show comment
Hide comment
@sgrif

sgrif Jun 9, 2014

Member

Thank you! 😄

Member

sgrif commented Jun 9, 2014

Thank you! 😄

+ ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
+ `cache_attributes` no longer has any effect. The default behavior has changed
+ to cache all attributes by default. There is no down-side to caching type
+ casting, and not caching mutable types can lead to unexpected behavior.

This comment has been minimized.

@jeremy

jeremy Jun 10, 2014

Member

"Calling cache_attributes is no longer necessary. All attributes are cached."

The last sentence talking about downsides makes sense to Rails implementors, not app developers.

@jeremy

jeremy Jun 10, 2014

Member

"Calling cache_attributes is no longer necessary. All attributes are cached."

The last sentence talking about downsides makes sense to Rails implementors, not app developers.

end
+ alias cached_attributes cache_attributes
+ alias cache_attribute? cache_attributes

This comment has been minimized.

@jeremy

jeremy Jun 10, 2014

Member

It's odd to get a cache_attributes deprecation when you call cached_attributes or cache_attribute?

@jeremy

jeremy Jun 10, 2014

Member

It's odd to get a cache_attributes deprecation when you call cached_attributes or cache_attribute?

@sgrif

This comment has been minimized.

Show comment
Hide comment
@sgrif

sgrif Jun 10, 2014

Member

Updated.

Member

sgrif commented Jun 10, 2014

Updated.

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy Jun 10, 2014

Member

👍

Member

jeremy commented Jun 10, 2014

👍

rm cached attributes
The original patch that added this concept can be found
[here](https://web.archive.org/web/20090601022739/http://dev.rubyonrails.org/ticket/9767).
The current default behavior is to cache everything except serialized
columns, unless the user specified otherwise. If anyone were to specify
otherwise, many types would actually be completely broken. Still, the
method is left in place with a deprecation warning in case anyone is
actually still calling this method.

rafaelfranca added a commit that referenced this pull request Jun 11, 2014

@rafaelfranca rafaelfranca merged commit 70b931f into rails:master Jun 11, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

sgrif added a commit to sgrif/protected_attributes that referenced this pull request Jun 14, 2014

@sgrif sgrif referenced this pull request in rails/protected_attributes Jun 14, 2014

Merged

No, AR:Base should not respond_to attribute_types_cached_by_default #37

@sgrif sgrif deleted the sgrif:sg-rm-cached-attributes branch Jun 14, 2014

@samwgoldman

This comment has been minimized.

Show comment
Hide comment
@samwgoldman

samwgoldman Aug 6, 2014

Sorry, I know this is old, but I am confused by this change. Why was it necessary? The comments indicate that many types would be broken, but which ones, and how? Why should string-valued attributes be cached?

Sorry, I know this is old, but I am confused by this change. Why was it necessary? The comments indicate that many types would be broken, but which ones, and how? Why should string-valued attributes be cached?

zzak added a commit that referenced this pull request Aug 20, 2014

Merge pull request #16597 from teeparham/master
Remove cached attributes from Configuring guide [ci skip]

This was removed in #15429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment