Hi all, i am migrating an aplication to Rails and it has some weird construct to handle References and DropDown Values, i was wondering how could i express this in Rails? i put it on http://pastie.caboo.se/79013 but in case it expires here is the DDL SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id OBJECT_ID(N''[dbo].[ReferenciasTipos_T]'') AND type in (N''U'')) BEGIN CREATE TABLE [dbo].[ReferenciasTipos_T]( [TipID] [int] IDENTITY(1,1) NOT NULL, [TipNombre] [nvarchar](200) NOT NULL, [TipDescripcion] [nvarchar](500) NULL, [TipIsNotas] [char](1) NOT NULL CONSTRAINT [DF_ReferenciasTipos_T_TipIsNotas] DEFAULT (''N''), [TipTituloNotas] [nvarchar](50) NULL, [TipTituloNotaUnaLinea] [nvarchar](100) NULL, [TipIsNotaUnaLinea] [char](1) NOT NULL CONSTRAINT [DF_ReferenciasTipos_T_TipIsNotaUnaLinea] DEFAULT (''N''), [TipPadreID] [int] NULL, [TipSystemUser] [char](1) NULL, [Creacion] [datetime] NOT NULL CONSTRAINT [DF_ReferenciasTipos_T_Creado] DEFAULT (getdate()), [Modificacion] [datetime] NOT NULL CONSTRAINT [DF_ReferenciasTipos_T_Modificado] DEFAULT (getdate()), [Creacion_UsrID] [int] NULL, [DeletedDate] [datetime] NULL, CONSTRAINT [PK_ReferenciasTipos_T] PRIMARY KEY CLUSTERED ( [TipID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id OBJECT_ID(N''[dbo].[ReferenciasValores_T]'') AND type in (N''U'')) BEGIN CREATE TABLE [dbo].[ReferenciasValores_T]( [ValorID] [int] IDENTITY(1,1) NOT NULL, [TipID] [int] NOT NULL, [ParentID] [int] NULL, [Descripcion] [nvarchar](200) NOT NULL, [Orden] [int] NULL CONSTRAINT [DF_ReferenciasValores_T_Orden] DEFAULT ((0)), [Notas] [text] NULL, [NotaUnaLinea] [nvarchar](50) NULL, [Creacion] [datetime] NOT NULL CONSTRAINT [DF_ReverenciasValores_Creado] DEFAULT (getdate()), [Modificacion] [datetime] NOT NULL CONSTRAINT [DF_ReverenciasValores_Modificado] DEFAULT (getdate()), [Creacion_UsrID] [int] NULL, [Comp_ID] [int] NULL, [DeletedDate] [datetime] NULL, CONSTRAINT [PK_ReverenciasValores] PRIMARY KEY CLUSTERED ( [ValorID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] END GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id OBJECT_ID(N''[dbo].[FK_ReferenciasTipos_T_ReferenciasTipos_T]'') AND parent_object_id = OBJECT_ID(N''[dbo].[ReferenciasTipos_T]'')) ALTER TABLE [dbo].[ReferenciasTipos_T] WITH CHECK ADD CONSTRAINT [FK_ReferenciasTipos_T_ReferenciasTipos_T] FOREIGN KEY([TipPadreID]) REFERENCES [dbo].[ReferenciasTipos_T] ([TipID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id OBJECT_ID(N''[dbo].[FK_ReferenciasValores_T_Usuarios_T]'') AND parent_object_id = OBJECT_ID(N''[dbo].[ReferenciasValores_T]'')) ALTER TABLE [dbo].[ReferenciasValores_T] WITH CHECK ADD CONSTRAINT [FK_ReferenciasValores_T_Usuarios_T] FOREIGN KEY([Creacion_UsrID]) REFERENCES [dbo].[Usuarios_T] ([UsrID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id OBJECT_ID(N''[dbo].[FK_ReverenciasValores_ReferenciasTipos_T]'') AND parent_object_id = OBJECT_ID(N''[dbo].[ReferenciasValores_T]'')) ALTER TABLE [dbo].[ReferenciasValores_T] WITH CHECK ADD CONSTRAINT [FK_ReverenciasValores_ReferenciasTipos_T] FOREIGN KEY([TipID]) REFERENCES [dbo].[ReferenciasTipos_T] ([TipID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id OBJECT_ID(N''[dbo].[FK_ReverenciasValores_ReverenciasValores]'') AND parent_object_id = OBJECT_ID(N''[dbo].[ReferenciasValores_T]'')) ALTER TABLE [dbo].[ReferenciasValores_T] WITH CHECK ADD CONSTRAINT [FK_ReverenciasValores_ReverenciasValores] FOREIGN KEY([ParentID]) REFERENCES [dbo].[ReferenciasValores_T] ([ValorID]) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---