ถามเรื่อง การ Create database กับ Type ที่เป็น ENUM ครับ

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1001 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1001 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

ผมเจอปัญหาเกี่ยวกับการ create database ครับ ปัญหาคืีอ ผมมีฟิลด์ที่เป็น ENUM แล้วเมื่อผมทำการ create ผมเจอ error ดังนี้ครับ

นี่คือส่วนโ้็ค้ดของผมใน File Migrate ครับ

 t.enum    "default_language",   :limit => [:th, :en]

ส่่วนนี้คือ error ครับ

rake aborted!
undefined method `enum' for #<ActiveRecord:: \
    ConnectionAdapters::TableDefinition:0x395c7f4>

อยากทราบว่าผมต้องทำการแ้ก้ปัญหาอย่างไรครับ รบกวนช่วยอธิบายด้วยครับ ขอบคุณมากครับ

apirak's picture

plugin enum_column ไม่รองรับ sexy migration ของ rails 2.0

ให้เพิ่ม file vendor/plugins/enum_column/lib/enum/table_definition.rb

module ActiveRecord
  module ConnectionAdapters #:nodoc:
    class TableDefinition
      def enum(*args)
        options = args.extract_options!
        column_names = args
 
        column_names.each { |name| column(name, 'enum', options) }
      end
    end
  end
end

แล้วก็ใส่ require ‘enum/table_definition’ ใน init.rb ของ plugin enum_column

ขอบคุณมากครับ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น