提交的表单无法在Rails中创建新记录

时间:2014-12-21 08:14:11

标签: ruby-on-rails

我想创建一个按钮(实际上是一个表单),它在我的Rails应用程序的Quantity模型中创建一个新记录。在我看来,我有这个:

<%= form_for :quantity, remote: true do |f| %>
  <%= f.hidden_field :number, value: 10 %>
  <%= f.hidden_field :user_id, value: current_user.id %>
  <%= f.submit "Add" %>
<% end %>

但是,每当我点击“添加”按钮时,应用程序都无法创建新记录。我不确定是什么问题。这是日志:

Processing by HomeController#search as JS
  Parameters: {"utf8"=>"✓", "quantity"=>{"number"=>"10", "user_id"=>"1"}, "commit"=>"Add"}
  Quantity Search (4.0ms)  curl http://localhost:9200/quantities_development/_search?pretty -d '{"query":{"dis_max":{"queries":[{"match":{"_all":{"query":"","operator":"and","boost":10,"analyzer":"searchkick_search"}}},{"match":{"_all":{"query":"","operator":"and","boost":10,"analyzer":"searchkick_search2"}}},{"match":{"_all":{"query":"","operator":"and","boost":1,"fuzziness":1,"max_expansions":3,"analyzer":"searchkick_search"}}},{"match":{"_all":{"query":"","operator":"and","boost":1,"fuzziness":1,"max_expansions":3,"analyzer":"searchkick_search2"}}}]}},"size":20,"from":0,"fields":[]}'
  Rendered home/search.html.erb within layouts/application (0.7ms)
  User Load (0.6ms)  SELECT  "users".* FROM "users"  WHERE "users"."id" = 1  ORDER BY "users"."id" ASC LIMIT 1
Completed 200 OK in 30ms (Views: 22.5ms | Searchkick: 4.0ms | ActiveRecord: 0.6ms)

这就是我的路线:

get 'search' => 'home#search'
post 'search' => 'home#search'

问题似乎是在一个视图中有多种形式。

0 个答案:

没有答案