2016-05-18 6 views
0

私はレールが初めてです。すべてがローカルではうまく動いていますが、英雄に展開した後、上記のエラーが表示されます。ここでNoMethodError(#Alll :: Nodes :: BindParam:0x007fe5554268b8のための未定義メソッド `val '):app/controllers/posts_controller.rb:10:` new'

はposts_controllersアクションです:

def new 
    @post = current_user.posts.build 
end 

、ここではschema.rbファイルの内容です:

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

    create_table "comments", force: :cascade do |t| 
    t.text  "comment" 
    t.integer "post_id" 
    t.integer "user_id" 
    t.datetime "created_at", null: false 
    t.datetime "updated_at", null: false 
    end 

    add_index "comments", ["post_id"], name: "index_comments_on_post_id" 
    add_index "comments", ["user_id"], name: "index_comments_on_user_id" 

    create_table "posts", force: :cascade do |t| 
    t.text  "description" 
    t.datetime "created_at",   null: false 
    t.datetime "updated_at",   null: false 
    t.string "image_file_name" 
    t.string "image_content_type" 
    t.integer "image_file_size" 
    t.datetime "image_updated_at" 
    t.integer "user_id" 
    end 

    create_table "users", force: :cascade do |t| 
    t.string "email",     default: "", null: false 
    t.string "encrypted_password",  default: "", null: false 
    t.string "reset_password_token" 
    t.datetime "reset_password_sent_at" 
    t.datetime "remember_created_at" 
    t.integer "sign_in_count",   default: 0, null: false 
    t.datetime "current_sign_in_at" 
    t.datetime "last_sign_in_at" 
    t.string "current_sign_in_ip" 
    t.string "last_sign_in_ip" 
    t.datetime "created_at",       null: false 
    t.datetime "updated_at",       null: false 
end 

add_index "users", ["email"], name: "index_users_on_email", unique: true 
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 

end 
+0

あなたは直面している –

+0

私はちょうど問題を解決しました: – Umerror

+0

@Umerrorあなたはあなた自身で問題を解決し、あなたの質問への回答を投稿し、他の人がそれから恩恵を受けることができるように受け入れてください。結局のところ、それはStackoverflowの目的です。 –

答えて

0

私は同じエラーが発生しました。 問題を解決するため、has_many関係の:foreign_keyを指定しました。

私の場合:私はFOREIGN_KEYが指定したため

class Assay::Attempt::Answer < ActiveRecord::Base belongs_to :assay_attempt, class_name: 'Assay::Attempt' end

class Assay::Attempt < ActiveRecord::Base has_many :answers, foreign_key: :assay_attempt_id # there wasn't foreign_key option end

0

私は4.2.0 Railsの上だけでなく、この出くわした、私の場合にはすべてのものは、何、大丈夫に見えましたforeign_keyとforeign_typeが記号ではなく文字列として指定されたときの問題を修正しました:

has_many :answers, foreign_key: :assay_attempt_id #this was not working 
has_many :answers, foreign_key: 'assay_attempt_id' #this was ok 
関連する問題