Sofia Vergara was almost arrested the day she got engaged.

The 'Modern Family' beauty's boyfriend Nick Loeb popped the question on a vacation to visit the pyramids at the Mayan archaeological site in the Yucatan peninsula, Mexico last year but they got in trouble when they scaled one of the monuments for the romantic moment.

Sofia told chat show host Ellen DeGeneres: ''He was like, let's go take a picture up there.

''He said he had gotten permission. I swear to God he said he had gotten permission to go up there and take a picture. So I said, 'OK, let's go.' So I went up, he took the ring out there. I made sure I like it.

''I like it, I put it on immediately and I said yes. And I checked, but then when we came down they want to arrest us because there were some nationals, no...local people got really upset and they thought I was [taking] advantage of the situation, but it was not true.''

Sofia previously revealed she did not want to wed again after her split from childhood sweetheart Joe Gonzalez nearly two decades ago, but thinks her engagement to Nick ''perfect'' timing.

Sofia - who has 20-year-old son Manolo from her relationship with Joe - said: ''I never really planned on getting married again. I had my son and it just wasn't a priority. But I love being in love, and I'm very happy right now. It's perfect.''