表单参数正确,但SQL遗漏了一个值
我有一张表格,看起来像这样,对不起,哈姆和德国部分表单参数正确,但SQL遗漏了一个值,sql,ruby-on-rails-3,forms,insert,Sql,Ruby On Rails 3,Forms,Insert,我有一张表格,看起来像这样,对不起,哈姆和德国部分 = form_for @mentality, :url => { :controller => "mentalities", :action => "create" }, :html => { :class => "mentality_create", :method => :post } do |f| = render 'shared/error_messages_einstellung', :
= form_for @mentality, :url => { :controller => "mentalities", :action => "create" }, :html => { :class => "mentality_create", :method => :post } do |f|
= render 'shared/error_messages_einstellung', :object => f.object
.left
%h4
Welche Einstellung möchten Sie hinzufügen?
= f.text_field :title, :placeholder => "Name der Einstellung"
%br
= f.submit "Eintragen"
还有一个模型是这样的:
# encoding: utf-8
class Mentality < ActiveRecord::Base
attr_accessible :title
belongs_to :user
validates :user_id, :presence => true
validates :title, :presence => true
default_scope :order => 'mentalities.created_at DESC'
self.per_page = 20
end
但它创建的SQL语句缺少标题:
INSERT INTO "mentalities" ("created_at", "title", "updated_at", "user_id") VALUES ('2011-11-13 11:26:48.078652', NULL, '2011-11-13 11:26:48.078652', 1)
我有一个simliar模型的控制器和视图,这个模型名为“categories”,工作非常好
那么,有人能解释一下为什么我的数据库中没有插入标题吗?我真的不明白为什么它不在那里。我不知道它是什么,但我只是删除了整个MVC并重新添加了它。看起来还是一样,但现在可以用了。修复了它。我刚刚删除了整个MVC并再次添加。我仍然不知道为什么会这样,但现在它起作用了。有时这才是最重要的:
INSERT INTO "mentalities" ("created_at", "title", "updated_at", "user_id") VALUES ('2011-11-13 11:26:48.078652', NULL, '2011-11-13 11:26:48.078652', 1)