ruby on rails - fetch different keys with different attributes(params) -


def appliance_params   params.require(:tv).permit(:x, y:, :z) end 

in example receive key 'tv' , values x, y, , z.

how can modify function receive different keys ?

this function can receive different appliances, can receive :iron, :computer etc... different values.

i receive 1 appliance in params.

def appliance_params   params.require(:tv).permit(:x, :y, :z) end 

is specific tv model.

to other params use:

params[:iron]

or if iron param part of tv take in permit call:

def appliance_params   params.require(:tv).permit(:x, :y, :z, :iron) end 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -