Displaying 20 results from an estimated 1000 matches similar to: "Re: How to model large SqlServer database"
2009 Jun 08
2
Connecting to SQLServer
New to rails. Installed rails on my XP desktop, and setup my first app
that will use an existing SQLServer database. I am able to connect to
SQLServer using odbc with following code.
require ''rubygems''
require ''ActiveRecord''
ActiveRecord::Base.establish_connection(
:adapter => ''sqlserver'',
:mode => ''odbc'',
:dsn
2005 Oct 05
0
has_and_belongs_to_many on legacy DB
I am working with mapping ActiveRecord onto a legacy database. All is going
well (using set_table_name, set_primary_key, etc), but I can''t get my
many<=>many relationships to work.
My contrived example of the situation:
Student has_and_belongs_to_many Teachers. This is mapped via table
student2teacher where the foreign keys are studentId and teacherId. The
primary key in Student
2006 Jun 14
0
Mssql Multiple Database Access Error
Hi All,
I am having a problem to access multiple databases with mssql
I am running Ruby 1.8.4 and Rails 1.1 on Windows 2000 Advanced Server.
I am simply trying to integrate the application I wrote before for
Oracle to Mssql. The application works perfectly with Oracle with the
installed driver OCI8. The app retrives data based on a search criteria
from those databases.
I followed the directions
2006 Feb 28
0
ActiveRecord: Legacy primary keys
Hi,
I''m building a frontend for a legacy schema, with tables like this:
CREATE TABLE `types` (
`a_type_cd` varchar(6) NOT NULL default '''',
`a_type` varchar(30) NOT NULL default '''',
PRIMARY KEY (`a_type_cd`)
);
The primary key is specified by the user (not auto-generated), and needs
to be updateable. I create the following a base class to
2006 May 15
8
set_table_name and self.table_name
I have some legacy tables that I used set_table_name on, I''m attempting
to write a method that will get key value from a sequence table and then
update it and return a value. I''m hoping to put this in the base
ActiveRecord method so I would like to reference the table name with
self.table_name or something...
class Contacts < ActiveRecord::Base
set_table_name
2006 Jan 18
3
legacy database on remote host
I''m getting this error in webrick then it crashes leaving nothing in the
log.
ruby: symbol lookup error:
/usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so: undefined symbol:
mysql_sqlstate
Here is the standard query I would normally write to get the data.
select * from child,parent
where CONCAT(SUBSTRING(child.item_number,1,14,''00'') =
parent.order_number and
2009 Apr 16
0
Magic multi connections with association problem
Dear all
I am using magic multi connections, there is some problem when using
association. How can I dynamic determine the module name (i.e.
A::Request, B::Request) in activerecord association.
Below is my code:
module A
establish_connection :A
end
module B
establish_connection :B
end
# and many module....
class Request < ActiveRecord::Base
set_table_name "request"
2006 Jul 25
2
join in legacy DB?
I''ve got a problem with some tables that don''t follow any RAILS
standards. how do I define the join in the model when all three tables
have wacky names?
class Machine < ActiveRecord::Base
set_table_name "tbl_CodeMgmt_Host"
set_primary_key "Id"
end
class Pool < ActiveRecord::Base
set_table_name "tbl_CodeMgmt_Pool"
set_primary_key
2006 Apr 11
1
Foreign Keys
Hi,
My tables are as follows:
"tblusers" - primary key "TblUsersID"
"tblregisteredphones" - primary key "TblRegisteredPhonesID"
- foreign key "intUserID"
My models are as follows:
class Registeredphone < ActiveRecord::Base
set_table_name "tblregisteredphones"
belongs_to :user,
:foreign_key
2008 Jan 23
1
Making Parents object attributes available
Hello,
I have a class Person
class Persoon < ActiveRecord::Base
set_table_name "Persoon"
set_primary_key "p_persoon"
has_many :adres, :class_name => "Adres"
composed_of :name, :class_name => Name, :mapping => [ [:naam,:naam],
[:voornaam,:voornaam], [:voornaam2,:voornaam2],
[:persnickname,:persnickname], [:perssortname,:perssortname] ]
def
2006 Feb 28
3
[AR] #{id} namespace visibility used in finder_sql
Dears,
[Rails 1.0.0]
I''m working with a legacy schema, and around my 20+ models i''ve used
some AR constructs.
They are based on a finder_sql doing some dirty sql and using #{id}
from the ''pivot'' model for extracting data in other tables.
like :
class Division < ActiveRecord::Base
set_table_name "legacy_division"
set_primary_key
2006 Jul 22
3
Connection refused - connect(2)
Dear all,
Please help me in this regards,
I am using models to access LegacySchemas using
set_table_name and set_primary_key...
[code for model]
class CdDetails < ActiveRecord::Base
def self.find_data
set_table_name ''cd_details''
set_primary_key ''cd_label''
find (:first,
:select => "cd_label")
end
2006 Jul 03
9
Migrations from Mysql to Oracle. PLS HELP!
Hi all,
I''m using Rails/Mysql as development platform. the production server is
under Rails/Oracle.
Right now, i''m trying to install my application under the production
server, the connection to orcale is fine via Rails, but i have a weird
problem. example :
here is a extract from my db scheme :
Table User :_____________
id_user |
first_name |
2007 Aug 11
0
Object herency problems
MOdel
Why when i put: Member.find(params[:id]).genealogy,
it tells: undefined method `genealogy'' for #<Matrix:0x4682280>
class Member < ActiveRecord::Base
set_primary_key :userid
has_many :matrix, :foreign_key => :userid
has_many :matrix, :foreign_key => :parent
def genealogy
result = matrix.clone
matrix.each do |m|
m.children.each do |c|
2005 Jul 25
0
sqlsever, scaffold and set_primary_key
I found what was wrong with sqlserver adapter. I can rename "id" to
other name and it works. Only scaffold does not work correctly. It
ignores my set_primary_key command and is looking for "id" name.
--
JZ
2006 Mar 03
0
AR::Base.pluralize_table_names doesnt work with scaffold generator, right?
Hi!
The script/generator scaffold for models doesnt respect (source in) this
config/environment.rb setup, right?
Because I can put in there ActiveRecord::Base.pluralize_table_names =
false but when I run a command like
ruby script/generate scaffold model Something
then it throws an error saying that my database scheme doesnt have a
Something. However there is a table called something.
If I
2013 Feb 10
0
Nested attributes doesnt get updated
Hi
Am building a nested form and my code works fine with sqlite3 but throws
errors when using Oracle during update action.
Am getting the following error:
ActiveRecord::RecordNotFound in AWRequestsController#update
Couldn''t find WADetail with ID=5000000015 for AWRequest with ID=5000000022.0
Request
*Parameters*:
{"utf8"=>"✓",
2010 Aug 19
1
Composite primary keys and :joins=>
I have a legacy db with the following simplified structure:
Table-A:
type_key, code_key, name, ... # PKs are type_key and code_key,
there is no id col and I cannot alter this db
Table-B: # each row has only the code as a foreign_key, the type_key
is hard-coded to "FOOKEY"
an_id, code, ...
Models:
class TableB < AR::Base
set_table_name ''table_b''
2006 Feb 14
6
[newb] Find vs Find :all question
I''m playing out with writing an online store.
So far it has accounts, addressbooks, and orders, and those 3 are tied
together with an customer ID. I also have orderDetails, which are
associated to the order via an order number. See models below...
When I do the following I can access the orderDetails information just
fine:
@order = Order.find(params[:id]) # i pass it a customer
2008 Apr 01
0
activerecord-sqlserver-adapter Gems Not Found HELP!!
Hi there,
I''m running ROR 2.x on Win32
tried to run gem install activerecord-sqlserver-adapter --source
http://gems.rubyonrails.org and get this:
D:\>gem install activerecord-sqlserver-adapter -source http://gems.rubyonrails.org
Bulk updating Gem source index for: http://gems.rubyonrails.org
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find