Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 设计确认后形成未初始化常数误差_Ruby On Rails_Ruby On Rails 4_Devise - Fatal编程技术网

Ruby on rails 设计确认后形成未初始化常数误差

Ruby on rails 设计确认后形成未初始化常数误差,ruby-on-rails,ruby-on-rails-4,devise,Ruby On Rails,Ruby On Rails 4,Devise,此应用程序基于Desive 3.0和Rails 4.1构建 我有一个用户对象,通过STI有两个子类(贷方和业务)。在企业注册并确认其电子邮件地址后,他们会被重定向到一个表单,以填写更多关于他们自己的信息(这些数据存储在一个名为SuppForm的新对象中)。 业务对象有一个支持表单。当业务部门确认他们的电子邮件并重定向到表单时,我收到一个错误 错误 ActionController::RoutingError (uninitialized constant SuppFormsController)

此应用程序基于Desive 3.0和Rails 4.1构建 我有一个用户对象,通过STI有两个子类(贷方和业务)。在企业注册并确认其电子邮件地址后,他们会被重定向到一个表单,以填写更多关于他们自己的信息(这些数据存储在一个名为SuppForm的新对象中)。 业务对象有一个支持表单。当业务部门确认他们的电子邮件并重定向到表单时,我收到一个错误

错误

ActionController::RoutingError (uninitialized constant SuppFormsController)
routes.rb(我将[]用于业务路线,因为我不希望它们与应用程序其他地方使用的路线重叠)

business.rb

class Business < User
  has_one :supp_form
  accepts_nested_attributes_for :supp_form
end
class SuppForm < ActiveRecord::Base
  belongs_to :business
end
class SuppFormController < ApplicationController
    before_filter :authenticate_user!

    def new
      @suppform = SuppForm.new
    end 

    private

    def supp_form_params
      params.require(:supp_form).permit(:first_name, :last_name, :work_phone_number, :business_address, :business_postal_code)
    end
end
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def account_url
    return new_user_session_url unless user_signed_in?
    case current_user.class.name
    when "Business"
      business_root_path
    when "Lender"
      lender_root_path
    else
      root_path
    end if user_signed_in?
  end

  def after_sign_in_path_for(resource)
    if resource.sign_in_count == 1 && resource.type == "Business"
      new_business_supp_form_path(resource.id)
    else 
      stored_location_for(resource) || account_url 
    end 
  end
class业务
补充表格rb

class Business < User
  has_one :supp_form
  accepts_nested_attributes_for :supp_form
end
class SuppForm < ActiveRecord::Base
  belongs_to :business
end
class SuppFormController < ApplicationController
    before_filter :authenticate_user!

    def new
      @suppform = SuppForm.new
    end 

    private

    def supp_form_params
      params.require(:supp_form).permit(:first_name, :last_name, :work_phone_number, :business_address, :business_postal_code)
    end
end
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def account_url
    return new_user_session_url unless user_signed_in?
    case current_user.class.name
    when "Business"
      business_root_path
    when "Lender"
      lender_root_path
    else
      root_path
    end if user_signed_in?
  end

  def after_sign_in_path_for(resource)
    if resource.sign_in_count == 1 && resource.type == "Business"
      new_business_supp_form_path(resource.id)
    else 
      stored_location_for(resource) || account_url 
    end 
  end
class-SuppForm
支持表单控制器.rb

class Business < User
  has_one :supp_form
  accepts_nested_attributes_for :supp_form
end
class SuppForm < ActiveRecord::Base
  belongs_to :business
end
class SuppFormController < ApplicationController
    before_filter :authenticate_user!

    def new
      @suppform = SuppForm.new
    end 

    private

    def supp_form_params
      params.require(:supp_form).permit(:first_name, :last_name, :work_phone_number, :business_address, :business_postal_code)
    end
end
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def account_url
    return new_user_session_url unless user_signed_in?
    case current_user.class.name
    when "Business"
      business_root_path
    when "Lender"
      lender_root_path
    else
      root_path
    end if user_signed_in?
  end

  def after_sign_in_path_for(resource)
    if resource.sign_in_count == 1 && resource.type == "Business"
      new_business_supp_form_path(resource.id)
    else 
      stored_location_for(resource) || account_url 
    end 
  end
class SupplFormController
应用程序\u控制器.rb

class Business < User
  has_one :supp_form
  accepts_nested_attributes_for :supp_form
end
class SuppForm < ActiveRecord::Base
  belongs_to :business
end
class SuppFormController < ApplicationController
    before_filter :authenticate_user!

    def new
      @suppform = SuppForm.new
    end 

    private

    def supp_form_params
      params.require(:supp_form).permit(:first_name, :last_name, :work_phone_number, :business_address, :business_postal_code)
    end
end
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def account_url
    return new_user_session_url unless user_signed_in?
    case current_user.class.name
    when "Business"
      business_root_path
    when "Lender"
      lender_root_path
    else
      root_path
    end if user_signed_in?
  end

  def after_sign_in_path_for(resource)
    if resource.sign_in_count == 1 && resource.type == "Business"
      new_business_supp_form_path(resource.id)
    else 
      stored_location_for(resource) || account_url 
    end 
  end
class ApplicationController

您可以在application_controller.rb中看到,我根据业务的登录次数将其重定向到supp_表单。我还尝试通过调用resource.ID并通过请求传递业务ID。我收到错误时的URL是:
http://xxxxxxxxxx/businesses/14/supp_form/new

看起来像是一个多元化问题。将控制器更改为复数名称

class SuppFormsController < ApplicationController
    before_filter :authenticate_user!
    # etc
end