I have a model called User. In the model I want to check if a value is true or false.
If the value is true then break all operations and redirect to a specific page.
How do I do that?
before_create :check_user
def check_user
if User.find_by_email(self.email)
redirect_to root_path
end
end
You can’t and you never need to redirect form model.
You should do it in controller something like