Hi guys,
Before opening a ticket, I want to be sure if this is a bug or not. Example:
class User < ActiveRecord::Base end
class Admin::User < ActiveRecord::Base end
And then:
class Account < ActiveRecord::Base belongs_to :user end
When I was calling Account.new.build_user, it was trying to create a new Admin::User because the default class_name is just "User". To fix the problem, I had to do:
class Account < ActiveRecord::Base belongs_to :user, :class_name => '::User' end
It also has problems in the opposite way:
class User < ActiveRecord::Base end
class Admin::User < ActiveRecord::Base end
And then:
class Admin::Account < ActiveRecord::Base belongs_to :user end
Sometimes Admin::Account.build_user is trying to build a ::User and other times ::Admin::User, because, again the default class_name is just "User".
My opinion is that in the first case, the class name should be by default "::User" and in the second it should be "::Admin::User".
The thing is, since the patch comes in, it will break apps that are relying in this wrong behavior. The good point is that the error will be raised when the application starts. The way it's now, takes quite sometime for you to discover that Account was trying to build a Admin::User instead of User.
Are you in or out for this change?
Regards,
José Valim.