【发布时间】:2018-02-22 08:31:49
【问题描述】:
试图将这些传递到表单中。
<% provide(:title,"Edit Type") %>
<% provide(:content,"Edit Type") %>
<% provide(:button,"Update") %>
<% provide(:link,"form_for(@type, url: product_type_path, method: :patch)") %> <!-- edit for product_type model(@type) url: go to product_type controller with update action -->
<%= render 'form' %>
_form.html.erb
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= yield(:link) do |f| %>
<h3><%= yield(:content) %></h3>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control' %>
<%= f.label :value %>
<%= f.number_field :value, class: 'form-control' %>
<%= f.submit yield(:button), class: "btn btn-primary" %>
<% end %>
</div>
</div>
生成的错误是隐式符号转换为整数或与关键字确保结尾有关的东西。
这有什么问题。
【问题讨论】:
-
我很确定你不能传递这样的表格。
-
那么使用大量提供和收益是不是很糟糕? @SergioTulentsev
标签: ruby-on-rails yield