Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 集合\u选择抛出错误_Ruby On Rails 3_Forms_Select - Fatal编程技术网

Ruby on rails 3 集合\u选择抛出错误

Ruby on rails 3 集合\u选择抛出错误,ruby-on-rails-3,forms,select,Ruby On Rails 3,Forms,Select,我在表单上有一个选择框,用于选择项目的类别类型: 它应该从project\u categories表中填充 迁移过程如下所示: class CreateProjectCategories < ActiveRecord::Migration def change create_table :project_categories do |t| t.string :category_name t.text :cat_desc t.

我在表单上有一个选择框,用于选择项目的类别类型:

它应该从
project\u categories
表中填充

迁移过程如下所示:

class CreateProjectCategories < ActiveRecord::Migration
  def change
    create_table :project_categories do |t|
      t.string    :category_name
      t.text      :cat_desc
      t.date      :created_on
      t.datetime  :updated_at
    end
  end
end
class CreateProjectCategories
My
project.rb
model deines
有一个:category
projectCategory.rb
模型定义
属于:project

我的
project\u categories
表中填充了数据。我从Rails指南中获得了语法,但它不起作用


有什么帮助吗?

好的,我的语法错了。最后的代码如下所示:

class CreateProjectCategories < ActiveRecord::Migration
  def change
    create_table :project_categories do |t|
      t.string    :category_name
      t.text      :cat_desc
      t.date      :created_on
      t.datetime  :updated_at
    end
  end
end

本质上,语法应该这样定义:警告:伪代码

不知道为什么API文档不能这么说