zoukankan      html  css  js  c++  java
  • This error is raised because the column 'type' is reserved for storing the class in case of inheritance

    ruby中,使用activerecord生产的数据访问类,结果出现如标题的错误
    “This error is raised because the column 'type' is reserved for storing the class in case of inheritance”

    google了下,原来是表中有type这个字段,而type应该是被ruby或者是activerecord作为一个保留字之类的,所以出现这个错误

    需要的做法是,给改个别名来访问

    Code
    class Rdevice < ActiveRecord::Base
     set_table_name 
    "devices"
     set_inheritance_column :ruby_type

     
    # getter for the "type" column
     def device_type
      self[:type]
     end

     
    # setter for the "type" column
     def device_type=(s)
      self[:type] 
    = s
     end
    end

    这样基本可以搞定

  • 相关阅读:
    rsync
    typora 页内跳转
    shell脚本搭建redis集群
    Html
    python json模块
    Appium
    selenium+python
    jmeter+ant+jenkins接口自动化测试框架
    测试小结
    面向对向
  • 原文地址:https://www.cnblogs.com/forward/p/1586170.html
Copyright © 2011-2022 走看看