Ich habe zwei Modelle, Themen und Benutzercreartor muss Fehler Ruby on Rails existieren
Benutzer:
class User < ApplicationRecord
has_many :created_issues, :class_name => 'Issue', :foreign_key => 'creator_id'
has_many :assigned_issues, :class_name => 'Issue', :foreign_key => 'assigned_id'
end
Ausgabe:
class Issue < ApplicationRecord
belongs_to :creator,
:class_name => "User",
:foreign_key => "creator_id"
belongs_to :assigned,
:class_name => "User",
:foreign_key => "assigned_id"
end
Migration Datei:
class CreateIssues < ActiveRecord::Migration[5.1]
def change
create_table :issues do |t|
t.string :title
t.text :description
t.integer :assigned_id
t.string :tipo
t.string :prioridad
t.string :estado
t.references :creator
t.references :assigned
add_foreign_key :issues, :users, column: :creator_id, primary_key: :id
add_foreign_key :issues, :users, column: :assigned_id, primary_key: :id
t.timestamps
end
end
end
Teil des Schemas:
ActiveRecord::Schema.define(version: 20171030104901) do
create_table "issues", force: :cascade do |t|
t.string "title"
t.text "description"
t.integer "assigned_id"
t.string "tipo"
t.string "prioridad"
t.string "estado"
t.integer "creator_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false`enter code here`
t.index ["assigned_id"], name: "index_issues_on_assigned_id"
t.index ["creator_id"], name: "index_issues_on_creator_id"
end
Ende
in Form erhalte ich, dass er Feld Creator muss vorhanden ist, aber ich sehe es gut im Einsatz:
Parameter:
{"utf8"=>"✓", "authenticity_token"=>"2yY/0x6961iIb9PxcyQAKHUSRqEj+zwQ91uPwHibU9tWjEXqiKMqp3vwzI70FVI2agtYhPgljFPDZjVZV4cmyg==", "issue"=>{"title"=>"asdsad", "description"=>"asdsa", "creator_id"=>"2", "tipo"=>"adas", "prioridad"=>"dsdaasd", "assigned_id"=>"3"}, "commit"=>"Create Issue"}
Unerreichter Parameter:: creator_id
(0,1 ms) beginnen Transaktion
User Load (0,3 ms)SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
(0,1 ms) Rollback-Transaktion
jede mögliche Hilfe?
damit gearbeitet. Es fehlte die Genehmigung. – Alberto