searched the tracker... but didn''t manage to find something like this:
>> User.table_name
=> "users"
>> User
=> User(id: integer, email: string, encrypted_password: string,
created_at: datetime, updated_at: datetime, remember_token: string,
remember_token_expires_at: datetime)
>> PendingUser.table_name
=> "pending_users"
>> PendingUser
=> PendingUser(id: integer, email: string, encrypted_password:
string, created_at: datetime, updated_at: datetime, remember_token:
string, remember_token_expires_at: datetime)
>> PendingUser.create! :email =>
''ara.t.howard@gmail.com'', :password
=> ''foobar''
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such
column: pending_users.email: SELECT * FROM users WHERE (LOWER
(pending_users.email) = ''ara.t.howard@gmail.com'') LIMIT 1
>> PendingUser.ancestors.map(&:name).first(3)
=> ["PendingUser", "User",
"ActiveRecord::Base"]
>> puts IO.read(''app/models/pending_user.rb'')
class PendingUser < User
set_table_name ''pending_users''
end
have i overlooked? Rails 2.0.1...
a @ http://drawohara.com/
--
sleep is the best meditation.
h.h. the 14th dalai lama
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---
> searched the tracker... but didn''t manage to find something like this: > > > >> User.table_name > => "users" > > > >> User > => User(id: integer, email: string, encrypted_password: string, > created_at: datetime, updated_at: datetime, remember_token: string, > remember_token_expires_at: datetime) > > > >> PendingUser.table_name > => "pending_users" > > > >> PendingUser > => PendingUser(id: integer, email: string, encrypted_password: > string, created_at: datetime, updated_at: datetime, remember_token: > string, remember_token_expires_at: datetime) > > > >> PendingUser.create! :email => ''ara.t.howard@gmail.com'', :password > => ''foobar'' > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such > column: pending_users.email: SELECT * FROM users WHERE (LOWER > (pending_users.email) = ''ara.t.howard@gmail.com'') LIMIT 1 > > > >> PendingUser.ancestors.map(&:name).first(3) > => ["PendingUser", "User", "ActiveRecord::Base"] > > > >> puts IO.read(''app/models/pending_user.rb'') > class PendingUser < User > set_table_name ''pending_users'' > end > > > > have i overlooked? Rails 2.0.1...AR only support single table inheritance, so what you''re trying to do won''t work. set_table_name should probably raise an exception to prevent you getting surprised like that though. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 22, 2008, at 4:18 PM, Michael Koziarski wrote:> > AR only support single table inheritance, so what you''re trying to do > won''t work. set_table_name should probably raise an exception to > prevent you getting surprised like that though. >seriously? the docs say: "If you don‘t have a type column defined in your table, single-table inheritance won‘t be triggered. In that case, it‘ll work just like normal subclasses with no special magic for differentiating between them or reloading the right type with find." and, of course, i have no type field... and, in the source ar/base.rb 1060 # True if this isn''t a concrete subclass needing a STI type condition. 1061 def descends_from_active_record? 1062 if superclass.abstract_class? 1063 superclass.descends_from_active_record? 1064 else 1065 superclass == Base || !columns_hash.include? (inheritance_column) 1066 end 1067 end which i was reading to be inline with the docs. also the code i posted has worked with previous versions of rails just fine... of course you would know! ;-) did i just get lucky before? kind regards. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> which i was reading to be inline with the docs. also the code i > posted has worked with previous versions of rails just fine... > > of course you would know! ;-)I *should* know, very different apparently :)> did i just get lucky before?I still am surprised it did work before, but assuming it did, and the fix is simple, I''m happy to take a patch :) -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 22, 2008, at 5:22 PM, Michael Koziarski wrote:> I *should* know, very different apparently :) > >> did i just get lucky before?lol!> > I still am surprised it did work before, but assuming it did, and the > fix is simple, I''m happy to take a patch :)well i may be on thin ice - not knowing what''s really intended in the source - but, unless someone chimes in that it really is *not* supposed to work i''ll have a go. cheers. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Jan 22, 2008 at 05:25:33PM -0700, ara.t.howard wrote:> > I still am surprised it did work before, but assuming it did, and the > > fix is simple, I''m happy to take a patch :) > > well i may be on thin ice - not knowing what''s really intended in the > source - but, unless someone chimes in that it really is *not* > supposed to work i''ll have a go.Considering that the docs say it should work, and the "least surprise" way would be to allow subclassing to work normally, I think a patch would be valuable. - Matt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> Considering that the docs say it should work, and the "least surprise" way > would be to allow subclassing to work normally, I think a patch would be > valuable.Absolutely. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---