This project is archived and is in readonly mode.

#953 ✓wontfix
Emilio Tagua

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

Reported by Emilio Tagua | September 1st, 2008 @ 11:05 PM | in 2.x

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.

Comments and changes to this ticket

  • Pratik

    Pratik December 20th, 2008 @ 05:39 PM

    • 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!

  • Emilio Tagua

    Emilio Tagua December 20th, 2008 @ 09:20 PM

    Pratik,

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

  • Frederick Cheung

    Frederick Cheung December 20th, 2008 @ 09:28 PM

    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)

  • Frederick Cheung

    Frederick Cheung December 20th, 2008 @ 09:39 PM

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

  • Pratik

    Pratik January 29th, 2009 @ 06:04 PM

    • Assigned user changed from “Pratik” to “Frederick Cheung”
  • Pratik

    Pratik May 18th, 2009 @ 09:49 PM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages