我有一个我存储东西的模型。当布尔属性(action_type)的值为false时,PostgreSQL由于某种原因回滚INSERT查询。
create_table :process_flows do |t|
t.integer :campaign_id
t.integer :position
t.string :description
t.string :typestr
t.float :action_number
t.boolean :action_type
t.string :action_on_donation
t.integer :created_by
t.integer :updated_by
t.timestamps
end
我的查看文件如下所示:
<%= form_for [@org, @campaign, @process_flow] do |f| %>
<%= render "shared/errors", :target => @process_flow %>
<div class="field">
<%= f.label :description %><br />
<%= f.text_field :description %>
</div>
<div class="field">
<%= f.label :typestr, 'Type of organization' %><br /><br />
<%= f.select :typestr, options_for_select([["Point of collection", "PC", :selected => true], ["Your Organization", "O"], ["Bank / Payment Gateway", "B"], ["Intermediary", "I"], ["Recipient Charity Project", "R"]]) %><br /><br />
</div>
<%= f.select :action_on_donation, options_for_select([["100% (Unchanged)", "U", :selected => true], ["Increase", "A"], ["Decrease", "S"]]) %>
the donation
by
<%= f.text_field :action_number, :style=>"width: 30px;", :value => '0' %>
<%= f.select :action_type, options_for_select([["Percent", '1', :selected => true], ["Flat Amount", '0']]) %>
<div>
<%= f.submit 'Add', :class=>'button' %>
</div>
<% end %>
答案 0 :(得分:0)
这可能发生在许多平台上。
最常见的原因是缺少COMMIT。当连接关闭时,PostgreSQL将回滚打开的事务。
另一种可能性是你有一个代码分支,即使你期望它也没有执行。
在这些情况下,重要的是通过遍历它来调试代码(此处没有足够的代码继续)并确定是否正在发送插入以及是否发出了提交。