No crea registro

agregue los isguiente al modelo de una relación en que use belongs_to
y no crea registros.
estoy usando sqlserver

MODELOS
Comuna
class Comuna < ActiveRecord::Base
belongs_to :region
validates_associated :region
validates_presence_of :nombre

def region
Region.find(region_id).nombre
end
end

Region
class Region < ActiveRecord::Base
has_many :comunas
end

el log da esto al tratar de crear una nueva comuna:

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:26) [POST]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“commit”=>“Save”, “action”=>“create”,
“controller”=>“comunas”, “comuna”=>{“nombre”=>“PARINACOTA”,
“region_id”=>“1”}}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
e[4;36;1mRegion Load (0.000000)e[0m e[0;1mSELECT TOP 1 * FROM
regiones WHERE (regiones.id = 1) e[0m
e[4;35;1mRegion Columns (0.015000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘regiones’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘regiones’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'regiones’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.01500 (31%) | 302 Found
[http://localhost/comunas/create]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:28) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.000000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:29) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.06200 (16 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:31) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.015000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.03100 (32 reqs/sec) | DB: 0.01500 (48%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:32) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.06300 (15 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:34) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.016000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.01600 (34%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:36) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.15600 (6 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:37) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.000000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:39) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:40) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.000000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.06200 (16 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:41) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.07800 (12 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:42) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.016000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.01600 (62 reqs/sec) | DB: 0.01600 (100%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:44) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.09400 (10 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:45) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.000000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.06200 (16 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:46) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04600 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:48) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.047000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.04700 (100%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:49) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.07800 (12 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:51) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.000000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:53) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.07900 (12 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:54) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;36;1mComuna Columns (0.000000)e[0m e[0;1mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.06300 (15 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Processing ComunasController#create (for 127.0.0.1 at 2007-02-07
00:14:56) [GET]
Session ID: 1b6f061bbd076b2e4465facc58b04ced
Parameters: {“action”=>“create”, “controller”=>“comunas”,
“comuna”=>“new”}
e[4;35;1mComuna Columns (0.000000)e[0m e[0mSELECT COLUMN_NAME as
ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType,
IS_NULLABLE As IsNullable, COL_LENGTH(‘comunas’, COLUMN_NAME) as
Length, COLUMNPROPERTY(OBJECT_ID(‘comunas’), COLUMN_NAME,
‘IsIdentity’) as IsIdentity, NUMERIC_SCALE as Scale FROM
INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comunas’e[0m
Redirected to http://localhost:3000/comunas/create?comuna=new
Completed in 0.04700 (21 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://localhost/comunas/create?comuna=new]

Y no crea nada, alguna idea, gracias.

Angel Mauricio Pino G
[email protected]
Movil: 08-577.92.72

On 2/7/07, Angel Mauricio Pino Gonzalez
[email protected] wrote:

    def region
            Region.find(region_id).nombre
    end

end

debe ser:

class Comuna < ActiveRecord::Base
belongs_to :region
validates_presence_of :region_id
validates_presence_of :nombre
end

y listo

fijate si anda