How to create a route in Rails that accepts a point url (.) ? type "[email protected]"

Asked

Viewed 166 times

0

Good morning,

I have an application where users register their information and the primary key of each user is their email. So in the method show the parameter I receive is the email.

However, default routes do not accept what comes after the point and when I try to access some user’s information, I get the error:

Couldn’t find Usuario with 'email'=usuario@gmail

and underneath, that:

Request

Parameters:

{"id"=>"user@gmail", "format"=>"com"}

I’ve tried to create custom routes but nothing works:

  match "usuarios/:email" => "usuarios#show", :via => [:get], :constraints => { :email => /.+@.+\..*/ }

I would really appreciate it if someone had a suggestion of what I should do

  • tries to change the regular expression to /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i

  • Gave another error: Regexp Anchor characters are not allowed in routing Requirements: / A[ w+-. ]+@[a-z d-]+(.[a-z]+)*. [a-z]+ z/i

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.