Param Is Missing or the Value Is Empty

Param is missing or the value is empty: ParameterMissing in ResultsController#update

The problem lies here:

params.require(:result).permit(:data)

From require documentation,

require ensures that a parameter is present. If it's present, returns
the parameter at the given key, otherwise raises an
ActionController::ParameterMissing error.

You are requiring result parameter but it's missing from the params. All your values are inside data param. Removing require should do the trick.

params.permit(:data)

If you want to keep require, wrap data inside result in forms.

param is missing or the value is empty: name -what exact value to put in require

Just make following changes in your controller,

def user_params
params.require(:user_crud).permit(:name, :email)
end

As your params contains form inputs under user_crud key.

param is missing or the value is empty: sale

Your strong params are looking for the following format, with sale as the root key:

{ "utf8"=>"✓", "sale" => {"country"=> "USA"} }

Based on your log, there aren't any params coming through the POST. Try putting a value into one of the inputs and committing the POST again to see if a param comes through. If it doesn't, try using Rails guides to step through this issue with your form setup.

Also, you are declaring that you expect sale to be the root key. You could also loosen this restriction by changing the sale_params method to be:

def sale_params
params.permit(:country, :state, :city, :street, :colony, :number, :postal_code)
end

which would allow your params to drop the root key:

{ "utf8"=>"✓", "country"=> "USA" }

Rails: param is missing or the value is empty: admin

I finally figured it out after careful examination of my logs.

Here's how I solved it:

I examined the request parameters of the create action and I realized that it was of this format:

{"authenticity_token"=>"qJWlHz7Z5myTH3dwNIjjSOzRDY7JN+LoovaG+8dMBnGFRWImJKlWp8cgF7kwTqJXIxqU2fGVkqW9nhOAJ8vFIg==",
"user_admin"=>{"email"=>"promise@gmail.com", "password"=>"[FILTERED]", "role"=>""},
"commit"=>"Create Admin"}

application trace screenshot

So the request parameters have a hash key of user_admin with values email, password and role, whereas I was passing the admin hash key in my admins_controller.

All I had to do was to modify the admins_params private method in my admins_controller:

From this:

def admin_params
params.require(:admin).permit(:email, :password, :role)
end

To this:

def admin_params
params.require(:user_admin).permit(:email, :password, :role)
end

and that solved the issue.

If you have such an issue, always endeavour to inspect your request parameters in your logs or your application trace. That will give you a lot of information that will help you to resolve the issue.

That's all.

I hope this helps

ActionController::ParameterMissing (param is missing or the value is empty: vendor

There are two problems: First, the strong params expect the input to be nested under vendor. Second, the strong params do not expect a nested renter_data hash.

To fix this in your query change the structure of the request data to:

{
"vendor": {
"vendor_id": 2,
"quote_type": "renter",
"first_name":"Tony",
"last_name":"Stark",
"email":"tony@starkindustries",
"phone_type":"mobile",
"phone":"6504881234",
"request_type":"renter",
"address1":"123 Main Street",
"address_city":"Palo Alto",
"address_state":"CA",
"address_zip":"94301",
"DOB":"1990-07-22"
}
}

If you want to keep the nested renter_data hash then you have to change the strong params like Paarth Agrawal already suggested. But then you still need to nest everything under vendor.



Related Topics



Leave a reply



Submit