I have a simple create action where I'm passing some params, but getting an error of undefined method permit for:
NoMethodError (undefined method `permit' for "twest":String):
following is the params that I'm getting in the request:
{"email"=>"[email protected]", "promo_code"=>"test", "description"=>"this is test", "action"=>"create"}
and the promo_code_params
def promo_code_params
params.require(:promo_code).permit(:email,:code, :description)
end
the create action
def create
@promo_code = @reward.promo_codes.new(promo_code_params)
# code
# code
end
Your params hash is not on the expected way your
promo_code_params
defines. It should look like:or you promo_code_params should be like:
Hope that helps you understand what's wrong.