Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Raise error when (re)naming columns on migration with ActiveRecord instance method names.

#953

As the title says Rails should raise an error when adding or renaming column(s) on a migration when trying to use an ActiveRecord instance method name.

This is helpful for preventing people to have conflicting methods with already existing methods from Active Record that may not be familiar with.

Reported by Emilio Tagua · September 1st, 2008 @ 11:05 PM

State: wontfix
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Pratik
    Pratik
    • Assigned user set to Pratik
    • State changed from new to incomplete

    Looks good to me. I wonder if we can make use of existing method instance_method_already_implemented? for this. Please catch me in IRC and we'll roll this in.

    Thanks!

    December 20th, 2008 @ 05:39 PM

  2. Emilio Tagua
    Emilio Tagua

    Pratik,

    Great suggestion, looks much better now, i believe my previous implementation was before instance_method_already_implemented? was in the core.

    December 20th, 2008 @ 09:20 PM

  3. Frederick Cheung
    Frederick Cheung

    Would another way around this be to hook method_added and use that? The reason I say that is that typically when I have had this problem it hasn't really been at the point of migration. If I had a column and stuff breaks then I know where to go.

    Much harder to diagnose is when a column you already have starts shadowing an important method, for example in one app I had a changed attribute that became problematic when I moved apps to 2.1 (clashes with dirty)

    December 20th, 2008 @ 09:28 PM

  4. Frederick Cheung
    Frederick Cheung

    Actually that would be really tough because of methods that it's fine to override (before_save, to_xml etc...).

    December 20th, 2008 @ 09:39 PM

  5. Pratik
    Pratik
    • Assigned user changed from Pratik to Frederick Cheung

    January 29th, 2009 @ 06:04 PM

  6. Pratik
    Pratik
    • Assigned user changed from Frederick Cheung to Pratik
    • State changed from incomplete to wontfix

    Rethinking this, I don't think it's worth fixing this.

    May 18th, 2009 @ 09:49 PM