我的控制器:
class SkyscraperApplicationsController < ApplicationController
def new
@skyscraper=SkyscraperApplications.new(skyscraper_params)
if @skyscraper.save
redirect_to "/skyscraper_applications/new", :notice => t("skyscraper_saved")
else
redirect_to "/skyscraper_applications/new", :notice => t("skyscraper_failed")
end
end
private
def skyscraper_params
params.require(:skyscraper_applications).permit(:name, :employee_count, :usecase, :email_admin, :what_you_do)
end
end
我在摩天大楼应用程序/new.html.erb 中的表格:
<form class="form-horizontal">
<%= simple_form_for @skyscraper do |f| %>
<div class="control-group">
<label class="control-label" for="name"><%=t ".company_name"%></label>
<div class="controls">
<div><%= f.input :name, :label=>false %></div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="employees"><%=t ".no_of_employees"%></label>
<div class="controls">
<div><%= f.input :employee_count, :label=>false %></div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="employees"><%=t ".usecase"%></label>
<div class="controls">
<%= f.select :usecase, options_for_select([["Select One", ""], "CAD/Render", "Video Production/Editing", "Music Production", "Game Design", "Email/Web", "Other"])%>
</div>
</div>
<div class="control-group">
<label class="control-label" for="Administrator"><%=t ".admin_email"%></label>
<div class="controls">
<div><%= f.input :email_admin, :label=>false %></div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="Administrator"><%=t ".what_you_do"%></label>
<div class="controls">
<div><%= f.input :what_you_do, :label=>false, :as => :text, :input_html => { :rows => 4 }%></div>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="test-drive-submit"><%= f.button :submit, t(".submit")%></div>
</div>
</div>
</form>
<%end%>
所以我不确定为什么会收到此错误,因为 :skyscraper_applications 在我的架构中添加所有字段都是正确的。我觉得我的方法和我的 simple_form_for 都很好。我对强参数做错了吗?提前致谢!