I am new to rails ,
I have added a new column “control_id” in a table users and same is added in model file under
attr_accessible :control_id
But when I use find_by_control_id(1) . I am getting undefined method error . Do I need to add the column any where else ?
code :
search_id = User.find_by_control_id(1).id
in the webhook i will get control_id , i need to use the control_id to find the id in users table
Thanks
It looks like there's no
userwithcontrol_id1 present in your DB, that's why it's thowingundefined method id for nilClasserror. You need to handle it in some way in your controller, like I am redirecting to root_path incase the query returnsnil.Hope that helps!