ActiveRecord::Base#attributes

I noticed that [8863] remove the :except and :only options from ActiveRecord::Base#attributes (and it makes perfect since not to duplicate Hash#except/slice in there). #attributes still takes an options parameter, but just ignores it, which could lead to a tricky to diagnose error further down the line. Could a deprecation notice not be issued (or make attributes not take an options parameter to that ArgumentError is raised if people try) to make this easier to spot?

Fred

I pointed this issue out in #rails-core but noone responded.

The strip_attributes[1] plugin is the only place I've seen using this feature; with [8863] the plugin would actually misbehave silently (stripping all attributes).

I think the option should be removed, and an appropriate upgrade strategy described in the release notes.

An alternative would be to do something like this: def attributes(options=nil)   if options     raise ArgumentError, 'The options argument is no longer accepted, please use Hash#except or Hash#slice' .. But I'd prefer the fiest approach as the simple fact that the feature was removed suggests that it is not commonly used and as such does not need special attention.

[1] http://rubyforge.org/projects/stripattributes

I noticed that [8863] remove the :except and :only options from ActiveRecord::Base#attributes (and it makes perfect since not to duplicate Hash#except/slice in there). #attributes still takes an options parameter, but just ignores it, which could lead to a tricky to diagnose error further down the line. Could a deprecation notice not be issued (or make attributes not take an options parameter to that ArgumentError is raised if people try) to make this easier to
spot?

I pointed this issue out in #rails-core but noone responded.

The strip_attributes[1] plugin is the only place I've seen using this feature; with [8863] the plugin would actually misbehave silently (stripping all attributes).

It's the silent stuff which is bad. Spent a good 15 minutes scratching
my head while trying out one of my apps

I think the option should be removed, and an appropriate upgrade strategy described in the release notes.

Sounds like a plan to me. I'm happy to knock up the (completely
trivial) patch.

Fred

An alternative would be to do something like this: def attributes(options=nil) if options    raise ArgumentError, 'The options argument is no longer accepted, please use Hash#except or Hash#slice' .. But I'd prefer the fiest approach as the simple fact that the feature was removed suggests that it is not commonly used and as such does not need special attention.

yes, perhaps a little over the top.

Sounds like a plan to me. I'm happy to knock up the (completely trivial) patch.

Sounds great, we should also add a deprecation warning to 2-0-stable, care to whip up both patches? :wink:

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/52-remove-argument-from-base-attributes-deprecate#ticket-52-1

Fred