【发布时间】:2011-10-26 17:11:15
【问题描述】:
我有一个模型用来存放东西。当布尔属性 (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 %>
【问题讨论】:
-
你能从你的日志中挖掘出 INSERT SQL 吗?是否有任何错误消息?
-
在 2011-08-14 15:02:45 +0530 ProcessFlowsController#create 开始为 127.0.0.1 发布“/orgs/fooddepot/campaigns/buy-food-give-food/process_flows”作为 HTML 参数:{"utf8"=>"✓", "authenticity_token"=>"if4a6oKMnidkdIJQp9dOL4pVX8FdyiPGao3McTij6Tg=", "process_flow"=>{"description"=>"Testing", "typestr"=>"I", "action_on_donation "=>"S", "action_number"=>"10", "action_type"=>"0"}, "commit"=>"Add", "org_id"=>"fooddepot", "campaign_id"=>"买食物送食物”}
-
SQL (0.2ms) BEGIN ProcessFlow Load (0.4ms) SELECT position FROM "process_flows" WHERE (process_flows.campaign_id = '1') ORDER BY position DESC, position ASC LIMIT 1 SQL (0.2ms) ROLLBACK 重定向到localhost:3000/orgs/fooddepot/campaigns/buy-food-give-food/… Completed 302 Found in 250ms
-
您有 INSERT 的日志条目吗?我在那里看不到
action_type。我真的想知道布尔值是否以0或'f'的身份进入数据库。 -
ROLLBACK 来自您的代码,它不是由 PostgreSQL 创建的。 PostgreSQL 仅记录您的应用程序发送的查询。
标签: ruby ruby-on-rails-3 heroku rails-postgresql heroku-postgres