ActiveRecord :: StatementInvalid(OCIError:ORA-01741:非法的零长度标识符:在“ SESSIONS”中删除“ SESSIONS”。“” =:a1)

时间:2018-11-13 13:19:46

标签: ruby-on-rails oracle session devise

在运行于mysql的ruby on rails应用程序中,我使用了devise gem进行身份验证,并将会话存储在数据库中。现在,我需要将其迁移到oracle。我将数据和表复制到Oracle并使用Oracle增强适配器连接到Oracle.Application已启动并且登录后出现以下错误

  ActiveRecord::StatementInvalid (OCIError: ORA-01741: illegal zero-length identifier: DELETE FROM "SESSIONS" WHERE "SESSIONS"."" = :a1):
    stmt.c:82:in oci8lib_230.so
    ruby-oci8 (2.1.8) lib/oci8/cursor.rb:28:in `initialize'
    ruby-oci8 (2.1.8) lib/oci8/oci8.rb:177:in `new'
    ruby-oci8 (2.1.8) lib/oci8/oci8.rb:177:in `parse_internal'
    ruby-oci8 (2.1.8) lib/oci8/oci8.rb:170:in `parse'
    /home/garima/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/delegate.rb:341:in `block in delegating_block'
    activerecord-oracle_enhanced-adapter (1.6.3) lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:109:in `prepare'

我创建了带有触发器的会话表以添加ID。我可以看到值正在添加到会话表中。

  class SessionsController < Devise::SessionsController
    prepend_before_filter :user_active?, only: [:new, :create]

    # before_action :configure_sign_in_params, only: [:create]
    around_action :time_zone, only: [:create]
    after_action :locale, only: [:create]

    def user_active?
      if (!params["user"].blank?)
        @user=User.find_by(:email => params["user"]["email"])
        if (!@user.blank?)
          if (!@user.active)
            flash[:error] = I18n.t('devise.failure.inactive')
          elsif (!@user.email_verification_status)
            flash[:error] = I18n.t('signup.verification.not_yet_verified')
          else
            return true
          end
        else
          flash[:error] = I18n.t('login.errors.invalid')
        end
        redirect_to "/signin"
      end
    end

    # GET /resource/sign_in
    def new
      @sign_in = true
      super
    end

    # POST /resource/sign_in
    def create
      super do |_resource|
      end
    end

  end

  class User < ActiveRecord::Base
    extend FriendlyId
    devise :database_authenticatable,
           :recoverable,  :trackable, :validatable, :timeoutable

    before_validation :strip_whitespace, :only => [:email]
    default_scope {where(clean_up: false)}
    has_many :store_user_assignments
    has_many :stores, through: :store_user_assignments
    has_and_belongs_to_many :clients, join_table: :clients_users
    has_many :store_user_assignments
    has_many :stores, through: :store_user_assignments
    belongs_to :profile

    # This is required in order to allow integrity constraints to work as expected since email is the primary key and it is case insensitive
    before_save {self.email = email.downcase}
    before_save :update_full_name
    after_create :create_slug

    # friendly_id :slug
    friendly_id :slug, use: :slugged
  end

0 个答案:

没有答案