I have a user model with attributes(not all required) first_name, last_name, birthday, profession, pet_name.
for registration the user needs to enter first_name and birthday.
I want to somehow get the attributes which are nil (in this case – last_name and profession) and randomly pick one of them and make a form asking the user to fill it in.
if I do @user.attributes.map{|k,v| v==nil ? k : nil}.compact I can get the attributes which are nil.
How do I make a form generic enough so that this method can be used on any attribute?
You can fill @field in the controller action for displaying form for additional field and then display a form for that field: