难以创建一个奇异的控制器(Rails)

时间:2018-04-02 11:27:49

标签: ruby-on-rails

我正在尝试创建一个没有“s”的模型和控制器,但我不断收到此错误

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation 
"holistic_feedbacks" does not exist
LINE 8:                WHERE a.attrelid = '"holistic_feedbacks"'::re...
                                      ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                 pg_get_expr(d.adbin, d.adrelid), a.attnotnull, 
a.atttypid, a.atttypmod,
         (SELECT c.collname FROM pg_collation c, pg_type t
           WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND 
a.attcollation <> t.typcollation),
                 col_description(a.attrelid, a.attnum) AS comment
            FROM pg_attribute a LEFT JOIN pg_attrdef d
              ON a.attrelid = d.adrelid AND a.attnum = d.adnum
           WHERE a.attrelid = '"holistic_feedbacks"'::regclass
             AND a.attnum > 0 AND NOT a.attisdropped
           ORDER BY a.attnum
):

1 个答案:

答案 0 :(得分:2)

Rails假设您将遵循惯例。如果不这样做,你需要告诉它你正在偏离路径。如果您已经运行了迁移并且您知道该表存在,则需要告知该表实际上是“holistic_feedback”。为此,请转到模型文件models/holistic_feedback.rb并添加:

self.table_name = "holistic_feedback"