Hello I have the following problem with my rails application:
I have two models, User and Information, the user, create his information using this url:
users/id/information/new
and edit his information using this url:
users/id/information/id/edit
The problem if the following, after the user create his information, if he go to the url:
users/id/information/new
the record is deleted from the data base and the user it’s allowed to create a new record; this is totally wrong, because the user is only allow to create one user information and then he can only edit his record.
How can I denied the user to go to new action url if the user have a record on the information table.
Thanks in advance.
add a before filter to the action new, then, inside that filter check if the user information exists
the filter will redirect and return false with a flash message if the user information exists, the code is an example, I don’t know your models