在部分膳食食品的布局中,我有以下代码:
<tr class="food food-tr-<%= meal_food.id %>">
<td><%= meal_food.name %></td>
<td>
<% form_for :meal_food, meal_food, url: { controller: "foods", action: "update" }, html: { class: "meal_food_servings-#{meal_food.id}" } do |f| %>
<%= f.number_field :servings %>
<% end %>
</td>
<td><%= pluralize(meal_food.serving_size, meal_food.measure_type) %></td>
<td><%= meal_food.fat %></td>
<td><%= meal_food.carbs %></td>
<td><%= meal_food.protien %> </td>
<td><%= link_to "x", food_path(meal_food.id), method: :delete, remote: true %> </td>
</tr>
在第二个 td 单元格中,我试图呈现一个提交给食品更新操作的小表单。
我一直遇到的错误是在简单地尝试呈现这些表格所在的膳食显示页面时出现的错误。
wrong number of arguments (3 for 2)
我在此处遵循 Rails 指南中的示例http://guides.rubyonrails.org/v2.3.11/form_helpers.html#binding-a-form-to-an-object
当我把
<%= meal_food %>
它输出一个meal_food 对象引用。所以我不确定这是否是问题所在。
谢谢!
---------- Routes.rb
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
resources :status_updates do
collection do
delete :delete_all
end
end
resources :meals
resources :foods do
collection do
get :search
end
end
devise_for :users, :controllers => { :registrations => "registrations" }
root to: 'static_pages#home'
match '/faq', to: 'static_pages#faq'
match '/contact', to: 'static_pages#contact'