TristinColby
asked on
Ruby ActiveRecord
I am trying to establish a connection then retrieve all the rows from a table. when i try to inherit from the ActiveRecord::Base, i get the following error: fixer.rb:14: superclass mismatch for class Data (TypeError). Can anyone tell me what is wrong here?
require 'active_record'
ActiveRecord::Base.establi sh_connect ion(
:adapter => 'sqlserver',
:host => 'servername',
:username => 'login',
:password => 'pass',
:database => 'db'
)
class Data < ActiveRecord::Base
end
require 'active_record'
ActiveRecord::Base.establi
:adapter => 'sqlserver',
:host => 'servername',
:username => 'login',
:password => 'pass',
:database => 'db'
)
class Data < ActiveRecord::Base
end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
aHA! found a limitation.
your class name and set_table_name values can't be the same.
so
class Blah < ActiveRecord::Base
#set_table_name 'Data'
#set_primary_key 'ServiceID'
end
will work, but
class Data < ActiveRecord::Base
set_table_name 'Data'
#set_primary_key 'ServiceID'
end
Will Not.
your class name and set_table_name values can't be the same.
so
class Blah < ActiveRecord::Base
#set_table_name 'Data'
#set_primary_key 'ServiceID'
end
will work, but
class Data < ActiveRecord::Base
set_table_name 'Data'
#set_primary_key 'ServiceID'
end
Will Not.
does that mean your problem is solved now?
ASKER
Yes
ASKER
class Data < ActiveRecord::Base
set_table_name 'Data'
#set_primary_key 'ServiceID'
end
Doesn't work.