[refs #18] changed refs id to string

This commit is contained in:
Alexander Machehin 2012-01-12 00:10:23 +06:00
parent dda40d9e9d
commit c18b71bf0b
3 changed files with 31 additions and 3 deletions

View File

@ -4,7 +4,11 @@ class Issue < ActiveRecord::Base
belongs_to :project
belongs_to :user
has_many :comments, :as => :commentable
has_many :comments, :as => :commentable,
:finder_sql => 'SELECT comments.* FROM comments ' +
'WHERE comments.commentable_id = \'#{self.id}\' ' +
' AND comments.commentable_type = \'#{self.class.name}\' ' +
'ORDER BY comments.created_at'
has_many :subscribes, :as => :subscribeable
validates :title, :body, :project_id, :presence => true

View File

@ -0,0 +1,9 @@
class ChangeCommentableId < ActiveRecord::Migration
def self.up
change_column :comments, :commentable_id, :string
end
def self.down
change_column :comments, :commentable_id, :integer
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111228182425) do
ActiveRecord::Schema.define(:version => 20120111080234) do
create_table "arches", :force => true do |t|
t.string "name", :null => false
@ -87,7 +87,7 @@ ActiveRecord::Schema.define(:version => 20111228182425) do
end
create_table "comments", :force => true do |t|
t.integer "commentable_id"
t.string "commentable_id"
t.string "commentable_type"
t.integer "user_id"
t.text "body"
@ -165,6 +165,13 @@ ActiveRecord::Schema.define(:version => 20111228182425) do
add_index "issues", ["project_id", "serial_id"], :name => "index_issues_on_project_id_and_serial_id", :unique => true
create_table "permissions", :force => true do |t|
t.integer "right_id"
t.integer "role_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "platforms", :force => true do |t|
t.string "description"
t.string "name"
@ -262,6 +269,14 @@ ActiveRecord::Schema.define(:version => 20111228182425) do
t.string "owner_type"
end
create_table "rights", :force => true do |t|
t.string "name", :null => false
t.string "controller", :null => false
t.string "action", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "rpms", :force => true do |t|
t.string "name", :null => false
t.integer "arch_id", :null => false