邀请类型字段值未使用会话hascode设置为Ror表单。在ror表单中显示无效类型

时间:2014-04-23 12:10:11

标签: ruby-on-rails ruby forms devise

我创建了一个表单,其中使用从邀请表生成的哈希码保存表单:

class VectorsController < ApplicationController

def create
    ui = UserInvitation.where(hash_code: session[:hash_code]).first
    @vendor = Vendor.new(vendor_params.merge({user_id: current_user.id, vendor_type: ui.try(:invitation_type)}))

    respond_to do |format|
      if @vendor.save

        ui.completed_registration = true
        ui.save

        session[:hash_code] = nil
        flash[:notice] = "You're all set! Welcome to Availendar!"

        format.html {redirect_to vendor_path(@vendor.id)}
      else
        flash[:alert] = "Oops, looks like there's been a problem. Please correct it and try again."

        format.html {render action: :invited_new}
      end
    end
  end

表单声称vendor_type无效 - 但在UserInvitation表中,值已在invitation_type字段中设置,但它没有显示vendor_type的值。 ..

可能是什么原因?是因为会话?我只想将invitation_type表中的UserInvitation设置为在向量控制器vendor_type操作中存储为/create值。如何设置值?

0 个答案:

没有答案