Forum: Ruby on Rails ActiveRecord private method called

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
97f7778bd994b7e4c5ad025be0640bde?d=identicon&s=25 Andrius Chamentauskas (Guest)
on 2008-12-15 00:55
(Received via mailing list)
Ok so i just upgraded to rails 2.2.2 and now i'm getting error
"Attempt to call private method". I found out that this is because my
planet model has attribute named y, which seems is a private attribute
in ActiveRecord::Base. I guess rails didn't check if it overwrites
private methods before and now it does. Problem is that i have so many
calls to this attribute that changing name is not really an option. I
was thinking about introducing public methods for it, but thought it
might break some ActiveRecord internals. Maybe someone knows any other
option?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-12-15 10:13
(Received via mailing list)
On Dec 14, 11:54 pm, Andrius Chamentauskas <sinsil...@gmail.com>
wrote:
> Ok so i just upgraded to rails 2.2.2 and now i'm getting error
> "Attempt to call private method". I found out that this is because my
> planet model has attribute named y, which seems is a private attribute
> in ActiveRecord::Base. I guess rails didn't check if it overwrites
> private methods before and now it does. Problem is that i have so many
> calls to this attribute that changing name is not really an option. I
Well I would still think that's the best option (and y is hardly a
describle option name)
> was thinking about introducing public methods for it, but thought it
> might break some ActiveRecord internals. Maybe someone knows any other
> option?
You could try sticking
ActiveRecord::Base.send :undef_method, :y

in an initializer.
This topic is locked and can not be replied to.