【发布时间】:2017-12-22 07:21:07
【问题描述】:
<h2>New Product</h2>
<%= form_for @product do|f| %>
<%= f.label :product_title %><br>
<%= f.text_field :product_title %><br>
<br>
<%= f.label :key_features %><br>
<%= f.text_area key_features %><br>
<br>
<%= f.label :price %>
<%= f.number_field :price %><br>
<br>
<%= f.label :colour %>
<%= f.number_field :colour %><br>
<br>
<%= f.label :main_material %>
<%= f.number_field :main_material %><br>
<br>
<%= f.submit %>
<% end %>
class ProductsController < ApplicationController
def home
@product = Product.all
end
def new
@product = Product.new
end
end
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string :product_title
t.text :key_features
t.integer :price
t.string :colour
t.string :main_material
t.timestamps null: false
end
end
end
为什么我会遇到这个错误?
【问题讨论】:
-
您在某处有一个模块
Product,它会影响您的活动记录模型。重命名其中一个。 -
使用
rails g model命令生成的Product模型还是您手动创建的? -
@anees 手动创建
标签: ruby-on-rails