Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #752 (closed enhancement: fixed)

Opened 3 years ago

Last modified 1 year ago

Overriding private methods should fail fast

Reported by: nzkoz Assigned to: NZKoz <michael@koziarski.com>
Priority: normal Milestone: 1.x
Component: ActiveSupport Version:
Severity: major Keywords: private send override
Cc: somekool@gmail.com, rails@bitsweat.net

Description

A common mistake that rails beginners make is to create an action 'send' or a model with an attribute 'open'. This often leads to extremely confusing stacktraces.

Ideally we should generate an error immediately rather than silently continuing until the internals call these now overriden methods.

Change History

03/02/05 00:39:44 changed by nzkoz

  • milestone set to 1.x.

04/27/05 14:47:13 changed by Mathieu

  • cc set to mathieu@ubertor.com.

same with model/controller/scaffold generator....

it should at least warn about reserved words.

see bug #435

08/19/05 01:14:45 changed by michael@schubert.cx

Idea: In development mode, like WhinyNil, we are Whiny and complain if they pick a reserved word?

08/19/05 02:04:27 changed by Michael@koziarski.Com

  • status changed from new to assigned.
  • severity changed from enhancement to blocker.
  • component changed from ActiveRecord to ActionMailer.
  • priority changed from normal to highest.
  • version deleted.
  • milestone changed from 1.x to 1.0.
  • owner changed from David to David.

We should complain even in production mode. It's something which will never work. Ideally they'll catch it earlier, but if it makes it through a silent failure is no better than a verbose one

08/19/05 05:48:25 changed by anonymous

Please refer to a solution in #844, which allows such names to be used without error.

08/19/05 06:02:21 changed by nzkoz

  • priority changed from highest to normal.
  • component changed from ActionMailer to ActiveRecord.
  • severity changed from blocker to major.

Stupid Opera for s60 did all those changes.

anonymous, what's the fix from #844? I must be missing something?

08/19/05 06:54:12 changed by anonymous

The fix from #844 is to remove all methods from the ActiveRecord::Base class so any name can be used as an action, even send and open.

08/26/05 23:49:37 changed by ulysses

We should complain even in production mode

The implementation would probably add additional overhead. I would recommend it be disabled in production mode but enabled in dev and test.

I should add that it is a moot argument until we have an implementation to argue over.

10/11/05 23:31:32 changed by herb

  • status changed from assigned to closed.
  • resolution set to duplicate.

david, i fixed this already. email me for the info...

10/11/05 23:53:23 changed by bitsweat

  • status changed from closed to reopened.
  • resolution deleted.

Please do not resolve tickets. Attach a patch with test cases. Thank you.

10/11/05 23:55:18 changed by bitsweat

  • status changed from reopened to new.
  • severity changed from major to enhancement.
  • component changed from ActiveRecord to ActiveSupport.
  • priority changed from normal to low.
  • owner changed from David to NZKoz <michael@koziarski.com>.
  • keywords set to private send override.

11/15/05 09:22:28 changed by bitsweat

  • cc changed from mathieu@ubertor.com to mathieu@ubertor.com, rails@bitsweat.net.
  • priority changed from low to normal.
  • severity changed from normal to major.
  • milestone changed from 1.0 to 1.x.

11/16/05 20:32:39 changed by anonymous

  • cc changed from mathieu@ubertor.com, rails@bitsweat.net to somekool@gmail.com, rails@bitsweat.net.

11/21/05 07:06:36 changed by bitsweat

(In [3124]) Turn warnings on when loading a file if Dependencies.mechanism == :load. Common mistakes such as redefined methods will print warnings to stderr. References #752. References #1792.

05/29/07 05:07:08 changed by josh

  • status changed from new to closed.
  • resolution set to fixed.

I guess [3124] fixes it.