Permalink
Browse files

Arreglo Status para que funcione como dice Rails

  • Loading branch information...
1 parent 8213c2f commit 427174180553a289dcf68ce2afbfad9898b6c980 @eloyesp eloyesp committed Apr 23, 2012
@@ -12,7 +12,7 @@ def tipo
Tipos[read_attribute(:tipo)] || "No indicado"
end
- belongs_to :estado, :foreign_key => :estado, :class_name => Status
+ belongs_to :estado, :class_name => Status
has_many :estados
@@ -2,9 +2,8 @@ class Status < ActiveRecord::Base
LEGACY_CONSTRAINTS = [:estado]
self.table_name = "status"
- self.primary_key = "estado"
- has_many :expedientes, :foreign_key => :estado
+ has_many :expedientes
def name
nombre
@@ -0,0 +1,23 @@
+class ReCreateStatus < ActiveRecord::Migration
+ def up
+ drop_table :status
+
+ create_table :status do |t|
+ t.integer :estado
+ t.string :nombre, :limit => 20
+
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :status
+
+ create_table :status, :primary_key => 'estado' do |t|
+ t.string :nombre, :limit => 20
+
+ t.timestamps
+ end
+ end
+end
+
@@ -0,0 +1,7 @@
+class AddEstadoIdToExpedientes < ActiveRecord::Migration
+ def change
+ add_column :expedientes, :estado_id, :integer
+ add_index :expedientes, :estado_id
+ end
+end
+
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120423142911) do
+ActiveRecord::Schema.define(:version => 20120423143611) do
create_table "active_admin_comments", :force => true do |t|
t.string "resource_id", :null => false
@@ -143,8 +143,10 @@
t.integer "etiq"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.integer "estado_id"
end
+ add_index "expedientes", ["estado_id"], :name => "index_expedientes_on_estado_id"
add_index "expedientes", ["numero", "pasada", "letra", "tipo"], :name => "index_expedientes_on_legacy_id"
create_table "finals", :force => true do |t|
@@ -238,7 +240,8 @@
add_index "sesions", ["expediente_id"], :name => "index_sesions_on_expediente_id"
- create_table "status", :primary_key => "estado", :force => true do |t|
+ create_table "status", :force => true do |t|
+ t.integer "estado"
t.string "nombre", :limit => 20
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false

0 comments on commit 4271741

Please sign in to comment.