我使用的是邪恶的宝石多步控制器,在我看来,似乎无法将用户实例传递给表单。
signup_step_controller
class Tenants::SignupStepsController < ApplicationController
include Wicked::Wizard
before_action :authenticate_tenant!
steps :account_link, :ach_setup, :payee_setup, :goal_setup
def show
@tenant = current_tenant
case step
when :account_link
@tenant.accounts.build if @tenant.accounts.blank?
@tenant.update_attributes(params[:accounts_params])
if @tenant.account.exchange_token.present?
skip_step
end
when :payee_setup
@tenant.payees.build if @tenant.payees.blank?
@tenant.payments.build if @tenant.payments.blank?
when :goal_setup
@tenant.build_escrow if @tenant.escrow.blank?
end
render_wizard @tenant
end
查看
<%= form_for @tenant, url: wizard_path(@tenant), method: :put, validate: true do |a| %> <!--fix this current_tenant not bing passed -->
<%= a.fields_for :accounts do |f| %>
<%= devise_error_messages! %>
<span class="form-group">
<%= f.label :bank_routing_number %>
<%= f.text_field(:routing, class: "sexy-input col-4") %>
...
我收到以下错误信息...
No route matches {:action=>"show", :controller=>"tenants/signup_steps", :id=>nil}
但是,如果我将表格更改为...
<%= form_for current_tenant, url: wizard_path(current_tenant), method: :put, validate: true do |a| %>
然后该表格可以工作,但我不知道为什么控制器没有通过租户又名用户。
还有一件事...
我的表单部分位于被调用的视图上...
<div class="col-lg-12">
<h1>Complete this form to setup basic ACH payment services</h1>
<div class="columns">
<%= render '_basic_ach_form.html.erb' %>
</div>
我需要将@tennat实例传递给局部对象吗?