jeudi 9 mars 2017

Rails strong params - using fields from has_many object

thanks a lot for your help.

In my rails project I have:

  • A location Model that has many :ads

    class Location < ApplicationRecord
        has_many :ads, :dependent => :destroy
    end
    
    
  • The Ad Model

  • In the controller developer_controller.rb I need to use with strong params the fields from location and ad

     params.require(:location).permit(:country, :location, :ads => [:remote, :days])
    
    

I don't know how to retrieve correctly the fields remote and days from the ad object.

Thanks a lot

Clinton

Aucun commentaire:

Enregistrer un commentaire