I have a model Peoples::Friend
and my friend.rb
is :
attr_accessible :name, :age
I removed this line because of mass assignment vulnerability. I have this controller peoples_controller.rb
friend = Peoples::Friend.update_attributes(:name => "test", :age => 23)
I removed the above line and added the following lines :
friend = Peoples::Friend.update_attributes(peoples_friend_params)
and added this function :
def peoples_friend_params
params.require(:peoples_friend).permit(:name, :age)
end
Now, when I run the API, it says ActionController::ParameterMissing (param is missing or the value is empty: peoples_friend)
What is wrong?
The problem was that the page from where I was calling this API sent params
instead of peoples_friend
. So, I did this :
params.permit(:name, :age)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.