找不到LeadsController#create的模板,渲染标头:no_content

问题描述 投票:0回答:1

因此,我试图将与我们联系的表单发送到保管箱,所以目标是让用户创建一个带有upload_file字段(附件)的销售线索(与我们联系的表单),然后我要询问该用户是否他想成为客户Irl,所以如果他成为一个客户Irl,我希望他领导中的附件(与他相关的联系表格)进入我的保管箱。

所以这是我与我们联系的管理员:

class LeadsController < ApplicationController
    require 'dropbox_api'
    skip_before_action :verify_authenticity_token
    def create
        @lead = Lead.new

        fullname = params['Name']
        company = params['Company']
        email = params['Email']
        phone = params['Phone']
        projectName = params['ProjectName']
        projectDescription = params['ProjectDescription']
        department_incharge = params['DepartmentInCharge']
        message = params['Message']
        attachment = params['attachment']


        @lead.full_name = fullname
        @lead.company_name = company
        @lead.email = email
        @lead.phone = phone
        @lead.project_name = projectName
        @lead.project_description = projectDescription
        @lead.department_in_charge = department_incharge
        @lead.message = message
        params_attach = attachment

        if params_attach
            @lead.attachment = params_attach.read
            @lead.original_filename = params_attach.original_filename


        client = DropboxApi::Client.new(ENV['DROPBOX_OAUTH_BEARER'])

        @lead.save!
        redirect_to root_path
        end
    end
 end

这是我的客户模型:

class Customer < ApplicationRecord
    has_many :lead
    has_many :buildings
    belongs_to :address
    belongs_to :user

    after_update :dropbox

   self.all.each do |lead|
    def dropbox
       self.lead.all.each do |lead|
         if lead.attachment != nil
           client = DropboxApi::Client.new(ENV['DROPBOX_OAUTH_BEARER'])
           client.create_folder("/#{lead.full_name}")
           client.upload("/#{lead.full_name}/#{File.basename(lead.original_filename)}", lead.attachment)
             # lead.file_attachment = nil
             # lead.original_filename = nil
             # lead.save!
             end
           end
       end
   end
end

问题是,当我按下发送按钮以确认报价时,它只是刷新页面(应该转到确认页面),并且在ubuntu控制台中,出现:

找不到LeadsController#create的模板,渲染头为:no_content在795毫秒内完成204内容不存在(ActiveRecord:0.0毫秒)

告诉我,如果您需要更多信息,我真的被困在那个位置上

ruby-on-rails api model controller dropbox
1个回答
0
投票

尝试一下,将redirect_toif中移出,添加快速消息以使其更清晰,我怀疑在这种情况下params_attachfalse / nil

if params_attach
   @lead.attachment = params_attach.read
   @lead.original_filename = params_attach.original_filename


   client = DropboxApi::Client.new(ENV['DROPBOX_OAUTH_BEARER'])

   @lead.save!

end
redirect_to root_path

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.