2016-10-05 25 views
0

私のアプリのコンテンツをCRUDするためにActiveAdminを実装しています。ここまでは順調ですね。 私はエラーを受け取りました:私の管理パネルでアクション「新規」にアクセスしているときに、Girl with and IDが見つかりませんでした。ID、Rails 4、ActiveAdminのレコードが見つかりません

enter image description here

マイ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 

変更しかし、それは問題を解決していませんでした。

ご協力いただきありがとうございます。

+0

を使用してみてください、 'girl_params'は何が起こっているかを紹介します置きます。または、pryのようなデバッガを使用することもできます。 –

+0

エラーが発生している行を教えてくれておらず、 'new'メソッドが問題ではないようです。 –

答えて

2

代わりの

format.html { render :action => "new" } 

が立ち往生している場合

format.html { redirect_to new_admin_girl_path } 
関連する問題