0

テーブルから連絡先を作成/編集または削除しようとするとエラーが発生します。ContactControllerのrailsとpostgresqlのActiveRecord :: StatementInvalid

私が持っている/編集作成しよう:

ActiveRecord::StatementInvalid in ContactController#create

PG::UndefinedFunction: ERROR: function get_xmlbinary() does not exist LINE 1: SELECT (get_xmlbinary() = 'base64')^HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: SELECT (get_xmlbinary() = 'base64') CONTEXT: PL/pgSQL function hc_contact_status() line 3 at IF : INSERT INTO "contact" ("lastname", "firstname", "name", "phone", "email") VALUES ($1, $2, $3, $4, $5) RETURNING "id"

を、私は削除しようとすると:

ActiveRecord::StatementInvalid in ContactController#create

PG::UndefinedFunction: ERROR: function hstore(contact) does not exist LINE 1: SELECT hstore(OLD.) - excluded_cols^HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: SELECT hstore(OLD.) - excluded_cols CONTEXT: PL/pgSQL function hc_contact_logger() line 18 at assignment : DELETE FROM "contact" WHERE "contact"."id" = $1

私はapplication_dbに「hstoreの」を追加することにguideを追ったが、それは表示されますERROR: extension "hstore" already exists

私は既存のデータベース(Salesforce)を使用しています。モデルコントローラとビューをコマンドラインrails generate scaffold contactで取得すると、ブラウザのデータベースの内容を表示できます。

contact_controller.rb:

class ContactController < ApplicationController 
    before_action :set_contact, only: [:show, :edit, :update, :destroy] 

    # GET /contacts 
    # GET /contacts.json 
    def index 
    @contact = Contact.all 
    end 

    # GET /contacts/1 
    # GET /contacts/1.json 
    def show 
    end 

    # GET /contacts/new 
    def new 
    @contact = Contact.new 
    end 

    # GET /contacts/1/edit 
    def edit 
    end 

    # POST /contacts 
    # POST /contacts.json 
    def create 
    @contact = Contact.new(contact_params) 

    respond_to do |format| 
     if @contact.save 
     format.html { redirect_to @contact, notice: 'Contact was successfully created.' } 
     format.json { render :show, status: :created, location: @contact } 
     else 
     format.html { render :new } 
     format.json { render json: @contact.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # PATCH/PUT /contacts/1 
    # PATCH/PUT /contacts/1.json 
    def update 
    respond_to do |format| 
     if @contact.update(contact_params) 
     format.html { redirect_to @contact, notice: 'Contact was successfully updated.' } 
     format.json { render :show, status: :ok, location: @contact } 
     else 
     format.html { render :edit } 
     format.json { render json: @contact.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    # DELETE /contacts/1 
    # DELETE /contacts/1.json 
    def destroy 
    @contact.destroy 
    respond_to do |format| 
     format.html { redirect_to @contact, notice: 'Contact was successfully destroyed.' } 
     format.json { head :no_content } 
    end 
    end 
    #contact_url 

    private 
    # Use callbacks to share common setup or constraints between actions. 
    def set_contact 
     @contact = Contact.find(params[:id]) 
    end 


    # Never trust parameters from the scary internet, only allow the white list through. 
    def contact_params 
     params.require(:contact).permit(:name, :lastname, :firstname, :phone, :email) 
    end 
end 

それが何をすることができますか?私はPSQLでそれを見つけた:あなたは "パブリック" のスキーマを含める必要が

hc_contact_logtrigger AFTER INSERT OR DELETE OR UPDATE ON salesforce.contact FOR EACH ROW WHEN (get_xmlbinary()::text = 'base64'::text) EXECUTE PROCEDURE salesforce.hc_contact_logger()

hc_contact_status_trigger BEFORE INSERT OR UPDATE ON salesforce.contact FOR EACH ROW EXECUTE PROCEDURE salesforce.hc_contact_status()

schema.rb

ActiveRecord::Schema.define(version: 0) do 

    enable_extension "plpgsql" 
    enable_extension "hstore" 

    create_table "_hcmeta", force: :cascade do |t| 
    t.string "org_id", limit: 50 
    t.text "details" 
    t.integer "hcver" 
    end 

    create_table "_sf_event_log", force: :cascade do |t| 
    t.string "table_name", limit: 128 
    t.string "action",  limit: 7 
    t.datetime "synced_at",    default: -> { "now()" } 
    t.datetime "sf_timestamp" 
    t.string "sfid",   limit: 20 
    t.text  "record" 
    t.boolean "processed" 
    t.index ["sfid"], name: "idx__sf_event_log_sfid", using: :btree 
    t.index ["table_name", "synced_at"], name: "idx__sf_event_log_comp_key", using: :btree 
    end 

    create_table "_trigger_last_id", id: false, force: :cascade do |t| 
    t.integer "trigger_log_id" 
    end 

    create_table "_trigger_log", force: :cascade do |t| 
    t.string "table_name", limit: 128 
    t.string "state",  limit: 8 
    t.string "sfid",   limit: 18 
    t.datetime "processed_at" 
    t.string "action",  limit: 7 
    t.datetime "updated_at",    default: -> { "now()" } 
    t.text  "old" 
    t.bigint "txid" 
    t.integer "record_id" 
    t.text  "sf_message" 
    t.datetime "created_at",    default: -> { "now()" } 
    t.text  "values" 
    t.integer "sf_result" 
    t.bigint "processed_tx" 
    t.index ["created_at"], name: "_trigger_log_idx_created_at", using: :btree 
    t.index ["state", "id"], name: "_trigger_log_idx_state_id", using: :btree 
    t.index ["state", "table_name"], name: "_trigger_log_idx_state_table_name", where: "(((state)::text = 'NEW'::text) OR ((state)::text = 'PENDING'::text))", using: :btree 
    end 

    create_table "_trigger_log_archive", id: :integer, force: :cascade do |t| 
    t.string "table_name", limit: 128 
    t.string "state",  limit: 8 
    t.string "sfid",   limit: 18 
    t.datetime "processed_at" 
    t.string "action",  limit: 7 
    t.datetime "updated_at" 
    t.text  "old" 
    t.bigint "txid" 
    t.integer "record_id" 
    t.text  "sf_message" 
    t.datetime "created_at" 
    t.text  "values" 
    t.integer "sf_result" 
    t.bigint "processed_tx" 
    t.index ["created_at"], name: "_trigger_log_archive_idx_created_at", using: :btree 
    t.index ["record_id"], name: "_trigger_log_archive_idx_record_id", using: :btree 
    t.index ["state", "table_name"], name: "_trigger_log_archive_idx_state_table_name", where: "((state)::text = 'FAILED'::text)", using: :btree 
    end 

    create_table "contact", force: :cascade do |t| 
    t.string "lastname",  limit: 80 
    t.string "firstname",  limit: 40 
    t.string "_hc_lastop",  limit: 32 
    t.datetime "systemmodstamp" 
    t.string "name",   limit: 121 
    t.text  "_hc_err" 
    t.string "sfid",   limit: 18 
    t.string "phone",   limit: 40 
    t.boolean "isdeleted" 
    t.datetime "createddate" 
    t.string "email",   limit: 80 
    t.index ["sfid"], name: "hcu_idx_contact_sfid", unique: true, using: :btree 
    t.index ["systemmodstamp"], name: "hc_idx_contact_systemmodstamp", using: :btree 
    end 

    create_table "product2", force: :cascade do |t| 
    t.text  "productimage__c" 
    t.datetime "createddate" 
    t.datetime "systemmodstamp" 
    t.boolean "isdeleted" 
    t.string "sfid",   limit: 18 
    t.string "name",   limit: 255 
    t.string "family",   limit: 40 
    t.string "_hc_lastop",  limit: 32 
    t.string "description",  limit: 4000 
    t.string "productcode",  limit: 255 
    t.text  "_hc_err" 
    t.index ["sfid"], name: "hcu_idx_product2_sfid", unique: true, using: :btree 
    t.index ["systemmodstamp"], name: "hc_idx_product2_systemmodstamp", using: :btree 
    end 

end 
+0

あなたの 'schema.rb'には何がありますか? –

+0

私はそれを解決した、残念ながら私は本当にどのように私は助けることができないのか分からない。 mu schema.rbを投稿すると、問題のある人を助けることができます – Tellimi

答えて

0

あなたには、いくつかの他のファイルが必要な場合は

EDITを依頼することを躊躇しませんあなたのschema_search_pathにデータベース.ymlへ

default: &default 
    ........... 
    schema_search_path: "salesforce,public" 

コンネctは、get_xmlbinaryという関数をデータベースのpublicスキーマに作成します。このスキーマは、同期プロセスの一部として使用されます。 search_pathからpublicスキーマを削除すると、Connectはその機能を見つけることができず、同期は失敗します。

関連する問題