0
私のアプリのコンテンツをCRUDするためにActiveAdminを実装しています。ここまでは順調ですね。 私はエラーを受け取りました:私の管理パネルでアクション「新規」にアクセスしているときに、Girl with and IDが見つかりませんでした。ID、Rails 4、ActiveAdminのレコードが見つかりません
マイActiveAdminコントローラ:
controller do
def create
@advertisement = Girl.new(girl_params)
respond_to do |format|
@advertisement.bypass_humanizer = true
if @advertisement.save
if params[:images]
params[:images].each { |image|
@advertisement.pictures.create(image: image)
}
end
format.html {redirect_to admin_girl_path(@advertisement)}
format.json { render :json => @advertisement, :status => :created, :location => @advertisement }
else
format.html { render :action => "new" }
format.json { render json: @advertisement.errors.full_messages, status: :unprocessable_entity }
end
end
end
def new
@advertisement = Girl.new
end
def edit
@advertisement = Girl.find(params[:id])
end
def update
@advertisement = Girl.find(params[:id])
flash[:notice] = 'Girl was successfully updated.' if @girl.update(girl_params)
redirect_to :back
end
def show
@advertisement = Girl.find(params[:id])
end
def destroy
@advertisement = Girl.find(params[:id])
@advertisement.destroy
redirect_to :back
end
def girl_params
# NOTE: Using `strong_parameters` gem
params.required(:girl).permit(:id,:humanizer_question_id, :_destroy, :confirmed_at,:bypass_humanizer,:humanizer_answer, :identifier, :token,:name, :work1,:subname,:paid, :work2, :check, :can_add_review,:work3, :work4,:smsidentifier,:smsidentifier_confirmation,:provaider, :expiration,:your_ip,:in_blacklist,:admin_confirmed,:country_id, :region_id,:user_id,:phone_number,:image,:terms_of_service,:region,:age,:height,:weight,:description,:description_ru,:email, hour_ids: [], pictures_attributes: [:image], service_ids: [])
end
end
私が起動するか見当もつかない。私は問題を見ることができません。
私が試した何:
はgirl_params
permit_params :id,:humanizer_question_id,...
へ
def create
@advertisement = Girl.new(permited_params[:girl])
end
変更しかし、それは問題を解決していませんでした。
ご協力いただきありがとうございます。
を使用してみてください、 'girl_params'は何が起こっているかを紹介します置きます。または、pryのようなデバッガを使用することもできます。 –
エラーが発生している行を教えてくれておらず、 'new'メソッドが問題ではないようです。 –