データベースに配列を挿入しようとしています。パラメータには配列(ステータス "=" {group_one "=>" one "、" group_two "=>" One "})が表示されますが、inot dbを挿入している間は省略されています。ハッシュをデータベースに挿入しない
以下が表示されます。ここでは
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"JgCBl8vcDAP9AUGaylk34om4mbKkxHCgM+GuAfxTL3sywaJkmvKL3pyS2C44MAkzMZ6AK+CUVv/Vmg9aUQYrZw==",
"irb"=>{"proposalno"=>"", "otherapptype"=>"", "titleofproject"=>"",
"date1"=>"", "date2"=>"", "date3"=>"", "fundingdetails"=>"",
"fund"=>"No internal funds or external funds are requested",
"datetobegindc"=>"", "rationale"=>"", "abstract"=>"",
"noofsub"=>"0", "natureofassociation"=>"",
"subjectselection"=>"", "confidentiality"=>"",
"howwhereconsent"=>"", "methodproceduresubjectparti"=>"",
"childrenpermission"=>"", "infowithheld"=>"",
"riskbenefitratio"=>"", "minimizingrisk"=>""},
"status"=>{"group_one"=>"One", "group_two"=>"One"},
"responsibility"=>{"nameoffac"=>"", "nameofinv"=>"",
"deptoffac"=>"", "deptofinv"=>"", "addoffac"=>"",
"addofinv"=>"", "phoneoffac"=>"", "phoneofinv"=>"",
"emailoffac"=>"", "emailofinv"=>""}, "commit"=>"SUBMIT MY DETAILS"}
(0.2ms) begin transaction
SQL (2.9ms) INSERT INTO "irbs" ("proposalno", "titleofproject",
"date1", "date2", "date3", "fund", "fundingdetails", "datetobegindc",
"rationale", "abstract", "noofsub", "natureofassociation",
"subjectselection", "confidentiality", "howwhereconsent",
"methodproceduresubjectparti", "childrenpermission", "infowithheld",
"riskbenefitratio", "minimizingrisk", "otherapptype", "created_at",
"updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?) [["proposalno", ""], ["titleofproject", ""],
["date1", ""], ["date2", ""], ["date3", ""],
["fund", "No internal funds or external funds are requested"],
["fundingdetails", ""], ["datetobegindc", ""], ["rationale", ""],
["abstract", ""], ["noofsub", "0"], ["natureofassociation", ""],
["subjectselection", ""], ["confidentiality", ""],
["howwhereconsent", ""], ["methodproceduresubjectparti", ""],
["childrenpermission", ""], ["infowithheld", ""],
["riskbenefitratio", ""], ["minimizingrisk", ""],
["otherapptype", ""], ["created_at", 2016-10-18 19:48:35 UTC],
["updated_at", 2016-10-18 19:48:35 UTC]]
は私のコントローラである:ここでは
class IrbsController < ApplicationController
def new
@irb = Irb.new
end
def create
@irb = Irb.new(irb_params)
if @irb.save
#RegistrationMailer.signup_confirmation(@registration).deliver
#log_in @user
flash[:success] = "Your details have been registered. A confirmation email has been sent."
redirect_to root_url
else
render 'new'
end
end
def index
end
def edit
end
def show
end
private
def irb_params
params.require(:irb).permit(:proposalno, :apptype, :titleofproject, :acc1, :date1, :acc2, :date2, :acc3, :date3, :projtype, :fund, :fundingdetails, :datetobegindc, :statusofprininv, :typeofreview, :rationale, :abstract, :noofsub, :assowithsub, :natureofassociation, :subjectselection, :ressubcomp, :adforresparti, :confidentiality, :voluntaryparticipation, :howwhereconsent, :methodproceduresubjectparti, :childrenpermission, :infowithheld, :risk, :riskbenefitratio, :minimizingrisk, :otherapptype, status:[])
end
end
移行です:
class CreateIrbs < ActiveRecord::Migration[5.0]
def change
create_table :irbs do |t|
t.string :proposalno
t.text :status
t.string :responsibility
t.string :apptype
t.string :titleofproject
t.string :acc1
t.string :date1
t.string :acc2
t.string :date2
t.string :acc3
t.string :date3
t.string :projtype
t.string :fund
t.string :fundingdetails
t.string :datetobegindc
t.string :statusofprininv
t.string :typeofreview
t.string :rationale
t.string :abstract
t.string :poputype
t.string :noofsub
t.string :assowithsub
t.string :natureofassociation
t.string :subjectselection
t.string :ressubcomp
t.string :adforresparti
t.string :confidentiality
t.string :voluntaryparticipation
t.string :howwhereconsent
t.string :methodproceduresubjectparti
t.string :childrenpermission
t.string :infowithheld
t.string :risk
t.string :riskbenefitratio
t.string :minimizingrisk
t.string :otherapptype
t.timestamps
end
end
end
モデルタラE:
class Irb < ApplicationRecord
serialize :status
end
あなたは、誰もがここで私は私のコントローラのコードを追加 –
@CdotStrifeVIIあなたを助けることができる前に、詳細を追加する必要があります。見てください。 – Sujith
おそらく私だけですが、パラメータリストに配列が見つかりません。あなたの配列の名前はどうですか? – spickermann