我创建了一个通过remote =>提交值的模态表单。 true(AJAX)并将其存储在数据库中。当记录保存在数据库中时,此功能有效。这是我的控制器代码:
respond_to :js, only: [:create_agent_confirmation]
def create_agent_confirmation
if @agent_confirm.validate(params[:agent_confirm])
@agent_confirm.save
respond_with(@agent_confirm, :location => root_path)
else
respond_with(@agent_confirm, :location => contact_path)
end
end
在我的模态(视图)中:
#agent_confirm_modal.small.reveal-modal{"data-reveal" => ""}
= simple_form_for [:customer, @agent_confirm], :url => create_agent_confirm_customers_path, :remote => true do |f|
.row
.sub-headline-secondary
.padding-16-balanced-bottom
= "Agent Confirmation"
.col-1-1-1.padding-16-all
.padding-12-bottom
= f.input :detail_verification, as: :boolean, label: "I have confirmed/updated the customer's details"
.padding-12-bottom
= f.input :document_verification, as: :boolean, label: "I have confirmed/updated the customer's documentation"
%a.close-reveal-modal= "×".html_safe
.padding-16-all.margin-gutter-bottom
= f.button :submit, "Submit", class: "button right tiny radius"
我的问题:
PS *我只需要在成功创建记录后重定向。
有什么想法吗?