我创建了一个表单,其中使用从邀请表生成的哈希码保存表单:
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
值。如何设置值?