我的控制器:
class SetupsController < ApplicationController
def new
@setup = Setup.new
@todays_rate = @setup.todays_rates.build
end
def create
@setup = Setup.new(params[:setup])
if @setup.save
redirect_to setup_path(@setup)
else
render 'new'
end
end
end
我的观看代码:setup / new.html.erb
<%= form_for @setup, :html => {:multipart => true} do |f| %>
<% if @setup.errors.any? %>
<ul>
<% @setup.errors.full_messages.each do |error| %>
<li><strong><%= error %></strong></li>
<% end %>
</ul>
<% end %>
<h4><%= f.label :effective_from, class:'required' %>
<%= f.text_field :effective_from %></h4>
<h4><%= f.label :effective_to, class:'required' %>
<%= f.text_field :effective_to %></h4>
<%= f.fields_for(:todays_rate) do |i| %> ##**combining two model with one view**
<h1>Interest Rate</h1>
<table cellpadding = "5px" cellspacing = "5px" width = "100%" class="table condensed-table"><tr>
<h4><th>Days From</th>
<th>Days To</th>
<th>Rate</th>
<th>Senior increment</th>
<th>Super Senior increment</th>
<th>Widow increment</th></h4>
</tr>
<h4><td><%= i.text_field :days_from, :class => 'input-mini' %></td></h4>
<h4> <td><%= i.text_field :days_to, :class => 'input-mini' %></td></h4>
<h4><td><%= i.text_field :rate, :class => 'input-mini' %></td></h4>
<h4> <td><%= i.text_field :senior_increment, :class => 'input-mini' %></td></h4>
<h4> <td><%= i.text_field :super_senior_increment,class:"input-mini" %></td></h4>
<h4><td><%= i.text_field :widow_incrtement,class: "input-mini" %></td></h4>
</table>
<% end %>
<fieldset class="form-actions"> <%= f.submit "Create Customer", class: "btn btn-primary" %></field>
setup.rb mmodel :
class Setup < ActiveRecord::Base
has_many :todays_rates
accepts_nested_attributes_for :todays_rates
attr_accessible :effective_from, :effective_to, :todays_rate
end
我在一个视图中合并了两个模型,但我得到了上述错误。我不知道我错过了关键字_end.can的任何人帮助我
答案 0 :(得分:0)
我认为您的问题是您尚未关闭表单,即模板末尾需要<% end %>
。
错误排序告诉你,虽然tIDENTIFIER的东西可以稍微抛出一点气味。